@xswap-link/sdk 0.3.3 → 0.3.4
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/CHANGELOG.md +8 -0
- package/dist/index.css +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.global.js +162 -451
- package/dist/index.js +427 -471
- package/dist/index.mjs +465 -509
- package/package.json +2 -2
- package/src/components/TxConfigForm/ConfirmationView/ErrorView.tsx +38 -0
- package/src/components/TxConfigForm/ConfirmationView/SuccessView.tsx +159 -0
- package/src/components/TxConfigForm/ConfirmationView/index.tsx +149 -0
- package/src/components/TxConfigForm/ConnectWalletPrompt.tsx +21 -0
- package/src/components/TxConfigForm/Form.tsx +83 -432
- package/src/components/TxConfigForm/index.tsx +6 -7
- package/src/components/global.css +0 -1
- package/src/constants/index.ts +1 -0
- package/src/models/payloads/GetSwapTxPayload.ts +1 -1
- package/src/services/api.ts +6 -1
- package/src/services/integrations/transactions.ts +4 -4
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useDebounce.tsx +0 -21
|
@@ -14,10 +14,9 @@ export type TxConfigFormProps = {
|
|
|
14
14
|
customContractCalls: ContractCall[];
|
|
15
15
|
desc?: string;
|
|
16
16
|
supportedChains: Chain[];
|
|
17
|
-
|
|
17
|
+
returnTransactions?: boolean;
|
|
18
18
|
dstDisplayTokenAddr?: string;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
20
|
const TxConfigForm = ({
|
|
22
21
|
integratorId,
|
|
23
22
|
dstChainId,
|
|
@@ -25,7 +24,7 @@ const TxConfigForm = ({
|
|
|
25
24
|
customContractCalls,
|
|
26
25
|
desc,
|
|
27
26
|
supportedChains,
|
|
28
|
-
|
|
27
|
+
returnTransactions,
|
|
29
28
|
dstDisplayTokenAddr,
|
|
30
29
|
onSubmit,
|
|
31
30
|
onClose,
|
|
@@ -64,7 +63,7 @@ const TxConfigForm = ({
|
|
|
64
63
|
desc={desc}
|
|
65
64
|
supportedChains={supportedChains}
|
|
66
65
|
wagmiConfig={wagmiConfig}
|
|
67
|
-
|
|
66
|
+
returnTransactions={!!returnTransactions}
|
|
68
67
|
dstDisplayTokenAddr={dstDisplayTokenAddr}
|
|
69
68
|
onSubmit={onSubmit}
|
|
70
69
|
onClose={onClose}
|
|
@@ -87,7 +86,7 @@ export const openTxConfigForm = async ({
|
|
|
87
86
|
customContractCalls,
|
|
88
87
|
desc,
|
|
89
88
|
supportedChains,
|
|
90
|
-
|
|
89
|
+
returnTransactions,
|
|
91
90
|
dstDisplayTokenAddr,
|
|
92
91
|
}: TxConfigFormProps): Promise<Route> => {
|
|
93
92
|
try {
|
|
@@ -107,10 +106,10 @@ export const openTxConfigForm = async ({
|
|
|
107
106
|
customContractCalls={customContractCalls}
|
|
108
107
|
desc={desc}
|
|
109
108
|
supportedChains={supportedChains}
|
|
110
|
-
|
|
109
|
+
returnTransactions={returnTransactions}
|
|
111
110
|
dstDisplayTokenAddr={dstDisplayTokenAddr}
|
|
112
111
|
onSubmit={(route) => {
|
|
113
|
-
if (
|
|
112
|
+
if (returnTransactions) {
|
|
114
113
|
resolve(route);
|
|
115
114
|
}
|
|
116
115
|
if (xpayRoot) {
|
package/src/constants/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export const MINIMUM_DISPLAYED_TOKEN_AMOUNT = 0.0001;
|
|
|
12
12
|
export const DEFAULT_SOURCE_CHAIN_ID = "1";
|
|
13
13
|
export const CCIP_EXPLORER = "https://ccip.chain.link/";
|
|
14
14
|
export const TX_RECEIPT_STATUS_LIFETIME = 60000;
|
|
15
|
+
export const DEFAULT_REQUEST_ABORT_MSG = "Request deprecated";
|
|
15
16
|
|
|
16
17
|
export const MSG_SENT_EVENT_SIG =
|
|
17
18
|
"MessageSent(bytes32,uint64,address,bytes,address,uint256,uint256,address,uint256)";
|
package/src/services/api.ts
CHANGED
|
@@ -38,11 +38,16 @@ async function _sendRequest<T>(
|
|
|
38
38
|
/**
|
|
39
39
|
* Get swap route based on provided criteria.
|
|
40
40
|
* @param payload required
|
|
41
|
+
* @param abortSignal
|
|
41
42
|
*/
|
|
42
|
-
export async function getRoute(
|
|
43
|
+
export async function getRoute(
|
|
44
|
+
payload: GetRoutePayload,
|
|
45
|
+
abortSignal?: AbortSignal,
|
|
46
|
+
): Promise<Route> {
|
|
43
47
|
return _sendRequest<Route>("/route", {
|
|
44
48
|
method: "POST",
|
|
45
49
|
body: JSON.stringify(payload),
|
|
50
|
+
signal: abortSignal,
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -14,7 +14,7 @@ export const openTransactionModal = async ({
|
|
|
14
14
|
dstToken,
|
|
15
15
|
customContractCalls = [],
|
|
16
16
|
desc,
|
|
17
|
-
|
|
17
|
+
returnTransactions,
|
|
18
18
|
dstDisplayToken,
|
|
19
19
|
}: GetSwapTxPayload): Promise<Transactions | undefined> => {
|
|
20
20
|
const supportedChains: Chain[] = (await getChains()).filter(
|
|
@@ -25,17 +25,17 @@ export const openTransactionModal = async ({
|
|
|
25
25
|
validateSwapTxData(supportedChains, dstChain, dstToken);
|
|
26
26
|
|
|
27
27
|
const route = await openTxConfigForm({
|
|
28
|
-
integratorId
|
|
28
|
+
integratorId,
|
|
29
29
|
dstChainId: dstChain,
|
|
30
30
|
dstTokenAddr: dstToken,
|
|
31
31
|
customContractCalls,
|
|
32
32
|
desc,
|
|
33
33
|
supportedChains,
|
|
34
|
-
|
|
34
|
+
returnTransactions,
|
|
35
35
|
dstDisplayTokenAddr: dstDisplayToken,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
if (
|
|
38
|
+
if (returnTransactions) {
|
|
39
39
|
return route.transactions;
|
|
40
40
|
}
|
|
41
41
|
};
|
package/src/hooks/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useDebounce";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export const useDebounce = (value: string, delay: number) => {
|
|
4
|
-
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
8
|
-
|
|
9
|
-
timeoutRef.current = setTimeout(() => {
|
|
10
|
-
setValue(value);
|
|
11
|
-
}, delay);
|
|
12
|
-
|
|
13
|
-
return () => {
|
|
14
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
15
|
-
};
|
|
16
|
-
}, [value, delay]);
|
|
17
|
-
|
|
18
|
-
const [debouncedValue, setValue] = useState(value);
|
|
19
|
-
|
|
20
|
-
return debouncedValue;
|
|
21
|
-
};
|