@multiversx/sdk-dapp-liquidity 2.1.0-alpha.4 → 2.1.1-alpha.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.
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -1
- package/helpers/index.mjs +18 -16
- package/helpers/isValidAddressForChainType.d.ts +3 -0
- package/helpers/isValidAddressForChainType.js +2 -0
- package/helpers/isValidAddressForChainType.mjs +37 -0
- package/helpers/tests/isValidAddressForChainType.spec.d.ts +1 -0
- package/helpers/tests/isValidAddressForChainType.spec.js +2 -0
- package/helpers/tests/isValidAddressForChainType.spec.mjs +102 -0
- package/index.js +1 -1
- package/index.mjs +162 -160
- package/package.json +3 -2
- package/reactjs/components/BridgeForm/Deposit.js +1 -1
- package/reactjs/components/BridgeForm/Deposit.mjs +269 -260
- package/reactjs/components/BridgeForm/Transfer.js +1 -1
- package/reactjs/components/BridgeForm/Transfer.mjs +210 -201
- package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -1
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +5 -3
- package/reactjs/components/Connect/BridgeConnectButton.js +1 -1
- package/reactjs/components/Connect/BridgeConnectButton.mjs +17 -14
- package/reactjs/hooks/useBridgeFormik.d.ts +6 -1
- package/reactjs/hooks/useBridgeFormik.js +1 -1
- package/reactjs/hooks/useBridgeFormik.mjs +94 -85
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +11 -9
- package/style.css +1 -1
package/index.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import { getTransactions as c } from "./api/getTransactions.mjs";
|
|
|
7
7
|
import { sendTransactions as l } from "./api/sendTransactions.mjs";
|
|
8
8
|
import { checkAccount as g } from "./api/checkAccount.mjs";
|
|
9
9
|
import { MVX_CHAIN_IDS as C } from "./constants/index.mjs";
|
|
10
|
-
import { decodeBase64 as
|
|
11
|
-
import { decodeLoginToken as
|
|
10
|
+
import { decodeBase64 as B, encodeToBase64 as k, isStringBase64 as v } from "./helpers/base64Utils.mjs";
|
|
11
|
+
import { decodeLoginToken as S } from "./helpers/decodeLoginToken.mjs";
|
|
12
12
|
import { decodeToken as I } from "./helpers/decodeToken.mjs";
|
|
13
13
|
import { getApiURL as F } from "./helpers/getApiURL.mjs";
|
|
14
14
|
import { getBridgeURL as R } from "./helpers/getBridgeURL.mjs";
|
|
@@ -17,183 +17,185 @@ import { getMvxApiURL as Q } from "./helpers/getMvxApiURL.mjs";
|
|
|
17
17
|
import { getMvxChainId as W } from "./helpers/getMvxChainId.mjs";
|
|
18
18
|
import { getMvxExplorerAddress as H } from "./helpers/getMvxExplorerAddress.mjs";
|
|
19
19
|
import { safeImageUrl as U } from "./helpers/safeImageUrl.mjs";
|
|
20
|
-
import {
|
|
20
|
+
import { isValidAddressForChainType as P } from "./helpers/isValidAddressForChainType.mjs";
|
|
21
|
+
import { serializeTransaction as z } from "./helpers/serializeTransaction.mjs";
|
|
21
22
|
/* empty css */
|
|
22
|
-
import { AccountAddress as
|
|
23
|
-
import { AmountCard as
|
|
24
|
-
import { AmountInput as
|
|
25
|
-
import { MxButton as
|
|
26
|
-
import { MxCard as
|
|
27
|
-
import { MxLink as
|
|
28
|
-
import { MxSearch as
|
|
29
|
-
import { MxSlideover as
|
|
30
|
-
import { MxTooltip as
|
|
31
|
-
import { BridgeForm as
|
|
32
|
-
import { BridgeHistory as
|
|
33
|
-
import { BridgeConnectButton as
|
|
34
|
-
import { CustomConnectButton as
|
|
35
|
-
import { MvxConnectButton as
|
|
36
|
-
import { SwitchChainButton as
|
|
37
|
-
import { BridgeAccountDisplay as
|
|
38
|
-
import { MvxAccountDisplay as
|
|
39
|
-
import { ChainSelectConnect as
|
|
40
|
-
import { CopyButton as
|
|
41
|
-
import { DisplayAmount as
|
|
42
|
-
import { SmallLoader as
|
|
43
|
-
import { TokenSelector as
|
|
44
|
-
import { TransactionToastContainer as
|
|
45
|
-
import { TransactionToast as
|
|
46
|
-
import { TrimAddress as
|
|
47
|
-
import { Error as
|
|
48
|
-
import { safeDocument as
|
|
49
|
-
import { Web3AppContext as
|
|
50
|
-
import { useWeb3App as
|
|
51
|
-
import { getQueryClient as
|
|
52
|
-
import { useAmountSchema as
|
|
53
|
-
import { useSecondAmountSchema as
|
|
54
|
-
import { useTestHasEnoughFunds as
|
|
55
|
-
import { useTestIsConnected as
|
|
56
|
-
import { useAccount as
|
|
57
|
-
import { useBalances as
|
|
58
|
-
import { BridgeFormikValuesEnum as
|
|
59
|
-
import { useDebounce as
|
|
60
|
-
import { useFetchBridgeData as
|
|
61
|
-
import { useFetchTokens as
|
|
62
|
-
import { useGetChainId as
|
|
63
|
-
import { useBridgeApiChainId as
|
|
64
|
-
import { useResolveTokenChain as
|
|
65
|
-
import { useSendTransactions as
|
|
66
|
-
import { useSignTransaction as
|
|
67
|
-
import { useSuiConnect as
|
|
68
|
-
import { SuiMethods as
|
|
69
|
-
import { useGetAllTokensQuery as
|
|
70
|
-
import { useGetChainsQuery as
|
|
71
|
-
import { useGetNonMvxTokensBalancesQuery as
|
|
72
|
-
import { useGetHistoryQuery as
|
|
73
|
-
import { useGetMvxTokensBalancesQuery as
|
|
74
|
-
import { useGetRateMutation as
|
|
75
|
-
import { delay as
|
|
76
|
-
import { formatAmount as
|
|
77
|
-
import { getCleanStringAmount as
|
|
78
|
-
import { getCompletePathname as
|
|
79
|
-
import { getInitialTokens as
|
|
80
|
-
import { hasEnoughFunds as
|
|
81
|
-
import { isStringFloat as
|
|
82
|
-
import { mxClsx as
|
|
83
|
-
import { pipe as
|
|
84
|
-
import { removeCommas as
|
|
85
|
-
import { roundAmount as
|
|
86
|
-
import { testNumber as
|
|
87
|
-
import { useAppKit as
|
|
88
|
-
import { useWaitForTransactionReceipt as
|
|
89
|
-
import { ALL_NETWORK_ID as
|
|
23
|
+
import { AccountAddress as X } from "./reactjs/components/AccountAddress/AccountAddress.mjs";
|
|
24
|
+
import { AmountCard as q } from "./reactjs/components/AmountCard/AmountCard.mjs";
|
|
25
|
+
import { AmountInput as Y } from "./reactjs/components/AmountInput/AmountInput.mjs";
|
|
26
|
+
import { MxButton as $ } from "./reactjs/components/base/MxButton/MxButton.mjs";
|
|
27
|
+
import { MxCard as oe } from "./reactjs/components/base/MxCard/MxCard.mjs";
|
|
28
|
+
import { MxLink as te } from "./reactjs/components/base/MxLink/MxLink.mjs";
|
|
29
|
+
import { MxSearch as me } from "./reactjs/components/base/MxSearch/MxSearch.mjs";
|
|
30
|
+
import { MxSlideover as se } from "./reactjs/components/base/MxSlideover/MxSlideover.mjs";
|
|
31
|
+
import { MxTooltip as fe } from "./reactjs/components/base/MxTooltip/MxTooltip.mjs";
|
|
32
|
+
import { BridgeForm as ie } from "./reactjs/components/BridgeForm/BridgeForm.mjs";
|
|
33
|
+
import { BridgeHistory as ce } from "./reactjs/components/BridgeHistory/BridgeHistory.mjs";
|
|
34
|
+
import { BridgeConnectButton as le } from "./reactjs/components/Connect/BridgeConnectButton.mjs";
|
|
35
|
+
import { CustomConnectButton as ge } from "./reactjs/components/Connect/CustomConnectButton.mjs";
|
|
36
|
+
import { MvxConnectButton as Ce } from "./reactjs/components/Connect/MvxConnectButton.mjs";
|
|
37
|
+
import { SwitchChainButton as Be } from "./reactjs/components/Connect/SwitchChainButton.mjs";
|
|
38
|
+
import { BridgeAccountDisplay as ve } from "./reactjs/components/Connect/BridgeAccountDisplay.mjs";
|
|
39
|
+
import { MvxAccountDisplay as Se } from "./reactjs/components/Connect/MvxAccountDisplay.mjs";
|
|
40
|
+
import { ChainSelectConnect as Ie } from "./reactjs/components/Connect/ChainSelectConnect.mjs";
|
|
41
|
+
import { CopyButton as Fe } from "./reactjs/components/CopyButton/CopyButton.mjs";
|
|
42
|
+
import { DisplayAmount as Re } from "./reactjs/components/DisplayAmount/DisplayAmount.mjs";
|
|
43
|
+
import { SmallLoader as Le } from "./reactjs/components/SmallLoader/SmallLoader.mjs";
|
|
44
|
+
import { TokenSelector as Qe } from "./reactjs/components/TokenSelector/TokenSelector.mjs";
|
|
45
|
+
import { TransactionToastContainer as We } from "./reactjs/components/TransactionToast/TransactionToastContainer.mjs";
|
|
46
|
+
import { TransactionToast as He } from "./reactjs/components/TransactionToast/TransactionToast.mjs";
|
|
47
|
+
import { TrimAddress as Ue } from "./reactjs/components/TrimAddress/TrimAddress.mjs";
|
|
48
|
+
import { Error as Pe } from "./reactjs/components/Error/Error.mjs";
|
|
49
|
+
import { safeDocument as ze, safeWindow as Oe } from "./reactjs/constants/index.mjs";
|
|
50
|
+
import { Web3AppContext as je, Web3AppProvider as qe } from "./reactjs/context/Web3AppProvider.mjs";
|
|
51
|
+
import { useWeb3App as Ye } from "./reactjs/context/useWeb3App.mjs";
|
|
52
|
+
import { getQueryClient as $e } from "./reactjs/context/queryClient.mjs";
|
|
53
|
+
import { useAmountSchema as oo } from "./reactjs/hooks/validation/useAmountSchema.mjs";
|
|
54
|
+
import { useSecondAmountSchema as to } from "./reactjs/hooks/validation/useSecondAmountSchema.mjs";
|
|
55
|
+
import { useTestHasEnoughFunds as mo } from "./reactjs/hooks/validation/useTestHasEnoughFunds.mjs";
|
|
56
|
+
import { useTestIsConnected as so } from "./reactjs/hooks/validation/useTestIsConnected.mjs";
|
|
57
|
+
import { useAccount as fo } from "./reactjs/hooks/useAccount.mjs";
|
|
58
|
+
import { useBalances as io } from "./reactjs/hooks/useBalances.mjs";
|
|
59
|
+
import { BridgeFormikValuesEnum as co, useBridgeFormik as lo } from "./reactjs/hooks/useBridgeFormik.mjs";
|
|
60
|
+
import { useDebounce as go } from "./reactjs/hooks/useDebounce.mjs";
|
|
61
|
+
import { useFetchBridgeData as Co } from "./reactjs/hooks/useFetchBridgeData.mjs";
|
|
62
|
+
import { useFetchTokens as Bo } from "./reactjs/hooks/useFetchTokens.mjs";
|
|
63
|
+
import { useGetChainId as vo } from "./reactjs/hooks/useGetChainId.mjs";
|
|
64
|
+
import { useBridgeApiChainId as So } from "./reactjs/hooks/useBridgeApiChainId.mjs";
|
|
65
|
+
import { useResolveTokenChain as Io } from "./reactjs/hooks/useResolveTokenChain.mjs";
|
|
66
|
+
import { useSendTransactions as Fo } from "./reactjs/hooks/useSendTransactions.mjs";
|
|
67
|
+
import { useSignTransaction as Ro } from "./reactjs/hooks/useSignTransaction.mjs";
|
|
68
|
+
import { useSuiConnect as Lo } from "./reactjs/hooks/useSuiConnect.mjs";
|
|
69
|
+
import { SuiMethods as Qo, init as Go } from "./reactjs/init/init.mjs";
|
|
70
|
+
import { useGetAllTokensQuery as bo } from "./reactjs/queries/useGetAllTokens.query.mjs";
|
|
71
|
+
import { useGetChainsQuery as wo } from "./reactjs/queries/useGetChains.query.mjs";
|
|
72
|
+
import { useGetNonMvxTokensBalancesQuery as _o, useInvalidateEvmTokensBalances as Po } from "./reactjs/queries/useGetNonMvxTokensBalances.query.mjs";
|
|
73
|
+
import { useGetHistoryQuery as zo, useInvalidateHistoryQuery as Oo } from "./reactjs/queries/useGetHistory.query.mjs";
|
|
74
|
+
import { useGetMvxTokensBalancesQuery as jo, useInvalidateMvxTokensBalancesQuery as qo } from "./reactjs/queries/useGetMvxTokensBalances.query.mjs";
|
|
75
|
+
import { useGetRateMutation as Yo } from "./reactjs/queries/useGetRate.mutation.mjs";
|
|
76
|
+
import { delay as $o } from "./reactjs/utils/delay.mjs";
|
|
77
|
+
import { formatAmount as or } from "./reactjs/utils/formatAmount.mjs";
|
|
78
|
+
import { getCleanStringAmount as tr } from "./reactjs/utils/getCleanStringAmount.mjs";
|
|
79
|
+
import { getCompletePathname as mr } from "./reactjs/utils/getCompletePathname.mjs";
|
|
80
|
+
import { getInitialTokens as sr } from "./reactjs/utils/getInitialTokens.mjs";
|
|
81
|
+
import { hasEnoughFunds as fr } from "./reactjs/utils/hasEnoughFunds.mjs";
|
|
82
|
+
import { isStringFloat as ir } from "./reactjs/utils/isStringFloat.mjs";
|
|
83
|
+
import { mxClsx as cr } from "./reactjs/utils/mxClsx.mjs";
|
|
84
|
+
import { pipe as lr } from "./reactjs/utils/pipe.mjs";
|
|
85
|
+
import { removeCommas as gr } from "./reactjs/utils/removeCommas.mjs";
|
|
86
|
+
import { roundAmount as Cr } from "./reactjs/utils/roundAmount.mjs";
|
|
87
|
+
import { testNumber as Br } from "./reactjs/utils/testNumber.mjs";
|
|
88
|
+
import { useAppKit as vr, useAppKitAccount as yr, useAppKitEvents as Sr, useAppKitNetwork as Mr, useAppKitNetworkCore as Ir, useAppKitProvider as Dr, useAppKitState as Fr, useAppKitTheme as Kr, useDisconnect as Rr, useWalletInfo as Er } from "@reown/appkit/react";
|
|
89
|
+
import { useWaitForTransactionReceipt as Nr } from "wagmi";
|
|
90
|
+
import { ALL_NETWORK_ID as Gr, ChainName as Wr, chainIdentifier as br } from "./reactjs/constants/chains.mjs";
|
|
90
91
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
92
|
+
Gr as ALL_NETWORK_ID,
|
|
93
|
+
X as AccountAddress,
|
|
94
|
+
q as AmountCard,
|
|
95
|
+
Y as AmountInput,
|
|
96
|
+
ve as BridgeAccountDisplay,
|
|
97
|
+
le as BridgeConnectButton,
|
|
98
|
+
ie as BridgeForm,
|
|
99
|
+
co as BridgeFormikValuesEnum,
|
|
100
|
+
ce as BridgeHistory,
|
|
101
|
+
Wr as ChainName,
|
|
102
|
+
Ie as ChainSelectConnect,
|
|
103
|
+
Fe as CopyButton,
|
|
104
|
+
ge as CustomConnectButton,
|
|
105
|
+
Re as DisplayAmount,
|
|
106
|
+
Pe as Error,
|
|
106
107
|
C as MVX_CHAIN_IDS,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
108
|
+
Se as MvxAccountDisplay,
|
|
109
|
+
Ce as MvxConnectButton,
|
|
110
|
+
$ as MxButton,
|
|
111
|
+
oe as MxCard,
|
|
112
|
+
te as MxLink,
|
|
113
|
+
me as MxSearch,
|
|
114
|
+
se as MxSlideover,
|
|
115
|
+
fe as MxTooltip,
|
|
116
|
+
Le as SmallLoader,
|
|
117
|
+
Qo as SuiMethods,
|
|
118
|
+
Be as SwitchChainButton,
|
|
119
|
+
Qe as TokenSelector,
|
|
120
|
+
He as TransactionToast,
|
|
121
|
+
We as TransactionToastContainer,
|
|
122
|
+
Ue as TrimAddress,
|
|
123
|
+
je as Web3AppContext,
|
|
124
|
+
qe as Web3AppProvider,
|
|
125
|
+
br as chainIdentifier,
|
|
125
126
|
g as checkAccount,
|
|
126
127
|
t as confirmRate,
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
B as decodeBase64,
|
|
129
|
+
S as decodeLoginToken,
|
|
129
130
|
I as decodeToken,
|
|
130
|
-
|
|
131
|
+
$o as delay,
|
|
131
132
|
k as encodeToBase64,
|
|
132
|
-
|
|
133
|
+
or as formatAmount,
|
|
133
134
|
F as getApiURL,
|
|
134
135
|
R as getBridgeURL,
|
|
135
136
|
m as getChains,
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
tr as getCleanStringAmount,
|
|
138
|
+
mr as getCompletePathname,
|
|
138
139
|
L as getDisplayName,
|
|
139
|
-
|
|
140
|
+
sr as getInitialTokens,
|
|
140
141
|
Q as getMvxApiURL,
|
|
141
142
|
W as getMvxChainId,
|
|
142
143
|
H as getMvxExplorerAddress,
|
|
143
|
-
|
|
144
|
+
$e as getQueryClient,
|
|
144
145
|
s as getRate,
|
|
145
146
|
f as getTokens,
|
|
146
147
|
i as getTokensBalances,
|
|
147
148
|
c as getTransactions,
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
fr as hasEnoughFunds,
|
|
150
|
+
Go as init,
|
|
150
151
|
v as isStringBase64,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
cr as
|
|
154
|
-
lr as
|
|
155
|
-
gr as
|
|
156
|
-
|
|
152
|
+
ir as isStringFloat,
|
|
153
|
+
P as isValidAddressForChainType,
|
|
154
|
+
cr as mxClsx,
|
|
155
|
+
lr as pipe,
|
|
156
|
+
gr as removeCommas,
|
|
157
|
+
Cr as roundAmount,
|
|
158
|
+
ze as safeDocument,
|
|
157
159
|
U as safeImageUrl,
|
|
158
|
-
|
|
160
|
+
Oe as safeWindow,
|
|
159
161
|
l as sendTransactions,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
162
|
+
z as serializeTransaction,
|
|
163
|
+
Br as testNumber,
|
|
164
|
+
fo as useAccount,
|
|
165
|
+
oo as useAmountSchema,
|
|
166
|
+
vr as useAppKit,
|
|
167
|
+
yr as useAppKitAccount,
|
|
168
|
+
Sr as useAppKitEvents,
|
|
169
|
+
Mr as useAppKitNetwork,
|
|
170
|
+
Ir as useAppKitNetworkCore,
|
|
171
|
+
Dr as useAppKitProvider,
|
|
172
|
+
Fr as useAppKitState,
|
|
173
|
+
Kr as useAppKitTheme,
|
|
174
|
+
io as useBalances,
|
|
175
|
+
So as useBridgeApiChainId,
|
|
176
|
+
lo as useBridgeFormik,
|
|
177
|
+
go as useDebounce,
|
|
178
|
+
Rr as useDisconnect,
|
|
179
|
+
Co as useFetchBridgeData,
|
|
180
|
+
Bo as useFetchTokens,
|
|
181
|
+
bo as useGetAllTokensQuery,
|
|
182
|
+
vo as useGetChainId,
|
|
183
|
+
wo as useGetChainsQuery,
|
|
184
|
+
zo as useGetHistoryQuery,
|
|
185
|
+
jo as useGetMvxTokensBalancesQuery,
|
|
186
|
+
_o as useGetNonMvxTokensBalancesQuery,
|
|
187
|
+
Yo as useGetRateMutation,
|
|
188
|
+
Po as useInvalidateEvmTokensBalances,
|
|
189
|
+
Oo as useInvalidateHistoryQuery,
|
|
190
|
+
qo as useInvalidateMvxTokensBalancesQuery,
|
|
191
|
+
Io as useResolveTokenChain,
|
|
192
|
+
to as useSecondAmountSchema,
|
|
193
|
+
Fo as useSendTransactions,
|
|
194
|
+
Ro as useSignTransaction,
|
|
195
|
+
Lo as useSuiConnect,
|
|
196
|
+
mo as useTestHasEnoughFunds,
|
|
197
|
+
so as useTestIsConnected,
|
|
198
|
+
Nr as useWaitForTransactionReceipt,
|
|
199
|
+
Er as useWalletInfo,
|
|
200
|
+
Ye as useWeb3App
|
|
199
201
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "MultiversX",
|
|
4
4
|
"description": "A complete toolkit for bridging assets between MultiversX, Ethereum, BNB Chain and Sui",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.1.
|
|
6
|
+
"version": "2.1.1-alpha.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/multiversx/mx-sdk-dapp-liquidity.git"
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@walletconnect/universal-provider": "2.23.9",
|
|
66
66
|
"animated-number-react": "0.1.2",
|
|
67
67
|
"axios": "1.16.0",
|
|
68
|
+
"bitcoinjs-lib": "7.0.1",
|
|
68
69
|
"formik": "2.4.9",
|
|
69
70
|
"lodash": "4.18.1",
|
|
70
71
|
"numeral": "2.0.6",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
"tailwindcss": ">= 3"
|
|
94
95
|
},
|
|
95
96
|
"devDependencies": {
|
|
96
|
-
"@multiversx/sdk-core": "15.4.
|
|
97
|
+
"@multiversx/sdk-core": "15.4.1",
|
|
97
98
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
98
99
|
"@swc-node/jest": "1.6.6",
|
|
99
100
|
"@swc/core": "1.5.24",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),js=require("@fortawesome/free-solid-svg-icons/faSpinner"),Is=require("@fortawesome/react-fontawesome"),Cs=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),Bs=require("@reown/appkit/react"),vs=require("@wagmi/core"),ys=require("lodash/debounce"),t=require("react"),k=require("react-toastify"),As=require("./hooks/useBridgeTokenSelection.js"),ks=require("./utils/bridgeFormHelpers.js"),Se=require("../../../constants/index.js"),Ss=require("../../../helpers/getApiURL.js");require("../../constants/index.js");const H=require("../../../helpers/safeImageUrl.js"),L=require("../../../types/chainType.js"),ws=require("../../context/useWeb3App.js"),T=require("../../helpers/resolveBridgeApiChainId.js"),Ns=require("../../hooks/useAccount.js"),Ms=require("../../hooks/useBridgeApiChainId.js"),S=require("../../hooks/useBridgeFormik.js"),Ds=require("../../hooks/useFetchBridgeData.js"),Fs=require("../../hooks/useGetChainId.js"),Rs=require("../../hooks/useSendTransactions.js"),Es=require("../../hooks/useSignTransaction.js"),Vs=require("../../queries/useGetHistory.query.js"),Ps=require("../../queries/useGetRate.mutation.js"),we=require("../../utils/mxClsx.js"),Ne=require("../AmountCard/AmountCard.js"),Me=require("../AmountInput/AmountInput.js"),Us=require("../base/MxButton/MxButton.js");require("../base/MxCard/MxCard.js");require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@fortawesome/free-solid-svg-icons/faClose");require("@headlessui/react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");const Hs=require("../BridgeHistory/BridgeHistory.js"),Ls=require("../Connect/BridgeConnectButton.js");require("wagmi");const Ts=require("../Connect/MvxConnectButton.js"),Os=require("../Connect/BridgeAccountDisplay.js"),Gs=require("../Connect/MvxAccountDisplay.js");require("@reown/appkit-controllers");const Ws=require("../ToggleDirection/ToggleDirection.js"),De=require("../TokenSelector/TokenSelector.js");let O;const Xs=({mvxChainId:G,mvxAddress:c,username:Fe,callbackRoute:Re="/",firstTokenIdentifier:Ee,secondTokenIdentifier:Ve,firstTokenAmount:w,secondTokenAmount:j,refetchTrigger:Pe,showHistory:Ue,forcedDestinationTokenSymbol:He,onSuccessfullySentTransaction:N,onFailedSentTransaction:f,onHistoryClose:M,onMvxConnect:re,onMvxDisconnect:Le,onNavigate:Te,onChangeDirection:Oe})=>{var je,Ie;const Ge=t.useRef(null),ae=t.useRef(void 0),[W,We]=t.useState(!1),[D,I]=t.useState(!1),[Xe,ze]=t.useState(1),[X,z]=t.useState(0),g=Ns.useAccount(),{switchNetwork:oe}=Bs.useAppKitNetwork(),ce=Vs.useInvalidateHistoryQuery(),{config:le,options:ue,supportedChains:C,nativeAuthToken:Q,bridgeOnly:Qe}=ws.useWeb3App(),$=Fs.useGetChainId(),de=Ms.useBridgeApiChainId(),{evmTokensWithBalances:$e,mvxTokensWithBalances:Ke,isTokensLoading:Ye,isLoadingEvmTokensBalances:Je,isLoadingMvxTokensBalances:Ze,chains:B=[],isChainsLoading:es}=Ds.useFetchBridgeData({refetchTrigger:Pe,mvxAddress:c,mvxApiURL:ue.mvxApiURL}),K=Ye||Je||Ze||es,ss=t.useMemo(()=>C.find(n=>T.sameBridgeApiChainId(n.id,$)),[$,C]),o=t.useMemo(()=>B.find(n=>n.chainId.toString()===G.toString()),[$,B]),{evm:me,solana:he,bitcoin:ge,sui:pe}=Es.useSignTransaction(),qe=Rs.useSendTransactions(),{mutate:ts,data:u,isPending:v,error:b}=Ps.useGetRateMutation(),y=((je=b==null?void 0:b.response)==null?void 0:je.status)===400?(Ie=b==null?void 0:b.response)==null?void 0:Ie.data.message:void 0,ns=t.useCallback(n=>{const q=C.find(l=>T.sameBridgeApiChainId(l.id,n.id));q&&oe(q)},[C,oe]),{firstToken:e,secondToken:a,fromOptions:F,toOptions:is,selectedChainOption:r,onChangeFirstSelect:fe,onChangeSecondSelect:rs,handleChangeDirection:as}=As.useBridgeTokenSelection({chains:B,activeChain:ss,sdkChains:C,switchNetwork:ns,fromTokens:$e,toTokens:Ke,firstTokenIdentifier:Ee,secondTokenIdentifier:Ve,forcedDestinationTokenSymbol:He,isTokensLoading:K,callbackRoute:Re,onNavigate:Te}),os=t.useMemo(()=>e?Se.MVX_CHAIN_IDS.includes(e.chainId.toString()):!1,[e==null?void 0:e.chainId]),cs=t.useMemo(()=>a?Se.MVX_CHAIN_IDS.includes(a.chainId.toString()):!1,[a==null?void 0:a.chainId]),[d,ls]=t.useState(w??""),[R,E]=t.useState(j??""),x=t.useMemo(()=>e?B.find(n=>T.sameBridgeApiChainId(n.chainId,e.chainId))??r:r,[e==null?void 0:e.chainId,B,r]),V=t.useMemo(()=>T.toBridgeApiChainId(e==null?void 0:e.chainId)??de,[e==null?void 0:e.chainId,de]),Y=g.address,be=g.isConnected&&!!Y,J=d!==""&&R!=="",Z=t.useCallback(ys(async n=>{!n||!Number(n)||!g.address||!(e!=null&&e.address)||!(a!=null&&a.address)||!r||!V||ts({nativeAuthToken:Q??"",body:{tokenIn:e.address,amountIn:n,fromChainId:V,tokenOut:a.address,toChainId:G}})},500),[g.address,V,e==null?void 0:e.address,a==null?void 0:a.address,r]),m=t.useCallback(n=>{ls(()=>n)},[]),_=t.useCallback(n=>{E(()=>n)},[]),us=t.useCallback(()=>{M==null||M()},[M]),ds=t.useCallback(()=>{const n=Cs.formatAmount({decimals:e==null?void 0:e.decimals,input:(e==null?void 0:e.balance)??"0",addCommas:!1,digits:4});p.setFieldValue("firstAmount",n),m(n)},[e==null?void 0:e.balance,e==null?void 0:e.decimals,m]),xe=t.useCallback(async n=>{m(""),_(""),ce(),ce(),N==null||N(n)},[m,_,N]),ms=()=>{as(),Oe()};t.useEffect(()=>{const n=ae.current;if(ae.current=r==null?void 0:r.chainId,!!n&&(r==null?void 0:r.chainId)!==(e==null?void 0:e.chainId)){const q=F==null?void 0:F.find(l=>l.chainId.toString()===(r==null?void 0:r.chainId));if(!q)return;fe(q)}},[r==null?void 0:r.chainId]);const hs=t.useCallback(async({transactions:n,provider:q})=>{var Ce,Be,ve;const l=[];I(!0),z(()=>n.length);try{let A=-1;for(const i of n){++A;try{switch(ks.resolveSigningChainType(i,x)){case L.ChainType.evm:{const h=await me.signTransaction({...i,value:BigInt(i.value),gas:BigInt(i.gasLimit),account:Y});if(!h||(l.push({...i,txHash:h}),A===n.length-1||!h))break;const U=await vs.waitForTransactionReceipt(le,{confirmations:1,hash:h});console.info({transactionReceipt:U,hash:h});break}case L.ChainType.sol:if(!i.instructions||!i.feePayer)break;const ie=await he.signTransaction({feePayer:i.feePayer,instructions:i.instructions,recentBlockhash:i.recentBlockhash});if(!ie)break;l.push({...i,txHash:ie});break;case L.ChainType.btc:if(!i.bitcoinParams){console.error("No bitcoin params");break}const _s=await ge.signTransaction(i.bitcoinParams);l.push({...i,txHash:_s});break;case L.ChainType.sui:{const h=(Ce=i.suiParams)==null?void 0:Ce.transactionBytes,U=(Be=i.suiParams)==null?void 0:Be.sender;if(!h||!U){console.error("No Sui transaction bytes or sender address");break}const ke=await pe.signTransaction({transaction:h,address:U});if(!ke)break;l.push({...i,suiParams:{...i.suiParams,signature:ke}});break}default:k.toast.error("Provider not supported"),I(!1);return}z(()=>n.length-1-A)}catch{k.toast.dismiss(),k.toast.error("Transaction aborted"),f==null||f("Transaction aborted"),I(!1);return}}const{data:ne}=await qe({transactions:l,provider:q,url:Ss.getApiURL()??"",token:Q??""}),ye=((ve=ne.transactions)==null?void 0:ve.map(i=>i.txHash).filter(i=>!!i))??[],Ae=l.map(i=>i.txHash).filter(i=>!!i),xs=ye.length>0?ye:Ae.length>0?Ae:ne.batchId?[ne.batchId]:[];xe(xs),I(!1)}catch(A){console.error(A),k.toast.dismiss(),k.toast.error("Transaction cancelled"),f==null||f("Transaction cancelled"),I(!1),z(0),ps(),m(""),_("")}},[x==null?void 0:x.chainType,Y,le,m,_,Q,xe,qe,ge.signTransaction,me.signTransaction,he.signTransaction,pe.signTransaction]),{formik:p,firstAmountError:ee,secondAmountError:se,fromChainError:te,handleBlur:P,handleChange:_e,handleSubmit:gs,resetSwapForm:ps}=S.useBridgeFormik({isMvxConnected:!!c,rate:u,sender:g.address??"",receiver:c??"",firstToken:e,firstAmount:d,fromChainId:V,toChainId:G,secondToken:a,secondAmount:R,setForceRefetchRate:ze,onSubmit:hs}),qs=!!(ee||se||te||y),fs=t.useMemo(()=>d!==""?y??ee:void 0,[ee,d,y]),bs=t.useMemo(()=>R!==""?te??se:void 0,[te,se,R]);return t.useEffect(()=>(d||E(""),Z(d),O&&clearInterval(O),O=setInterval(()=>{Z(d)},50*1e3),()=>clearInterval(O)),[d,Xe,Z]),t.useEffect(()=>{u!=null&&u.amountOut&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,u.amountOut),E(u.amountOut))},[u==null?void 0:u.amountOut]),t.useEffect(()=>{y&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,"0"),E("0"))},[y]),t.useEffect(()=>{w&&(p.setFieldValue(S.BridgeFormikValuesEnum.firstAmount,w),m(w))},[]),t.useEffect(()=>{j&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,j),_(j))},[j]),s.jsx(s.Fragment,{children:s.jsxs("form",{ref:Ge,noValidate:!0,className:"liq-flex liq-flex-col liq-gap-1 liq-relative",autoComplete:"off",onSubmit:gs,children:[Ue&&s.jsx(Hs.BridgeHistory,{mvxAddress:c,onClose:us}),s.jsxs(Ne.AmountCard,{className:we.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"From"}),s.jsx(Os.BridgeAccountDisplay,{disabled:v,activeChain:x})]}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Me.AmountInput,{inputName:"firstAmount",inputValue:p.values.firstAmount,amountError:fs,disabled:!1,onInputDebounceChange:m,onInputChange:_e,onBlur:P}),s.jsx(De.TokenSelector,{name:"firstToken",disabled:v,options:F,areOptionsLoading:K,isMvxSelector:os,isDestination:!1,color:"neutral-850",onChange:fe,onBlur:P,onMaxBtnClick:ds,selectedOption:e,onTokenSelectorDisplay:n=>We(n)})]})]}),s.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:Qe&&s.jsx(Ws.ToggleDirection,{onChangeDirection:ms})}),s.jsxs(Ne.AmountCard,{className:we.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"To"}),s.jsx(Gs.MvxAccountDisplay,{accountAddress:c,chainIcon:H.safeImageUrl(o==null?void 0:o.pngUrl),username:Fe,accountExplorerUrl:`${ue.mvxExplorerAddress}/accounts/${c}`,showTag:!0,onDisconnect:Le,onConnect:re})]}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Me.AmountInput,{inputName:"secondAmount",inputValue:p.values.secondAmount,amountError:bs,disabled:!1,onInputDebounceChange:_,onInputChange:_e,onBlur:P}),s.jsx(De.TokenSelector,{name:"secondToken",disabled:v,omitDisableClass:!0,options:is,areOptionsLoading:K,isMvxSelector:cs,color:"neutral-850",onChange:rs,onBlur:P,selectedOption:a})]})]}),s.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!c&&s.jsx(Ts.MvxConnectButton,{mvxAccountAddress:c,icon:H.safeImageUrl(o==null?void 0:o.pngUrl),onClick:re}),c&&!be&&s.jsx(Ls.BridgeConnectButton,{className:"liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",disabled:v,activeChain:x}),c&&be&&s.jsxs(Us.MxButton,{type:"submit",variant:"neutral-850",className:"liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",disabled:!J||v||!c||!g.address||qs||D,children:[J&&!D&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx("div",{children:"Deposit on "}),s.jsx("img",{src:H.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]}),!J&&!D&&s.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"}),D&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx(Is.FontAwesomeIcon,{icon:js.faSpinner,spin:!0,className:"liq-mx-1 liq-flex liq-items-center"}),s.jsx("div",{children:"Depositing on"}),s.jsx("img",{src:H.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]})]})]}),g.address&&X>0&&s.jsx("div",{className:"liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm",children:s.jsxs("div",{children:["You will be asked to sign ",X," ",X>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Deposit=Xs;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Cs=require("@fortawesome/free-solid-svg-icons/faSpinner"),vs=require("@fortawesome/react-fontawesome"),Bs=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),ys=require("@reown/appkit/react"),As=require("@wagmi/core"),ks=require("lodash/debounce"),t=require("react"),k=require("react-toastify"),Ss=require("./hooks/useBridgeTokenSelection.js"),Ns=require("./utils/bridgeFormHelpers.js"),we=require("../../../constants/index.js"),ws=require("../../../helpers/getApiURL.js");require("../../constants/index.js");const H=require("../../../helpers/safeImageUrl.js");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");const S=require("../../../types/chainType.js"),Ms=require("../../context/useWeb3App.js"),L=require("../../helpers/resolveBridgeApiChainId.js"),Ds=require("../../hooks/useAccount.js"),Es=require("../../hooks/useBridgeApiChainId.js"),N=require("../../hooks/useBridgeFormik.js"),Fs=require("../../hooks/useFetchBridgeData.js"),Rs=require("../../hooks/useGetChainId.js"),Vs=require("../../hooks/useSendTransactions.js"),Ps=require("../../hooks/useSignTransaction.js"),Ts=require("../../queries/useGetHistory.query.js"),Us=require("../../queries/useGetRate.mutation.js"),Me=require("../../utils/mxClsx.js"),De=require("../AmountCard/AmountCard.js"),Ee=require("../AmountInput/AmountInput.js"),Hs=require("../base/MxButton/MxButton.js");require("../base/MxCard/MxCard.js");require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@fortawesome/free-solid-svg-icons/faClose");require("@headlessui/react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");const Ls=require("../BridgeHistory/BridgeHistory.js"),Os=require("../Connect/BridgeConnectButton.js");require("wagmi");const Gs=require("../Connect/MvxConnectButton.js"),Ws=require("../Connect/BridgeAccountDisplay.js"),Xs=require("../Connect/MvxAccountDisplay.js");require("@reown/appkit-controllers");const zs=require("../ToggleDirection/ToggleDirection.js"),Fe=require("../TokenSelector/TokenSelector.js");let O;const Qs=({mvxChainId:G,mvxAddress:c,username:Re,callbackRoute:Ve="/",firstTokenIdentifier:Pe,secondTokenIdentifier:Te,firstTokenAmount:w,secondTokenAmount:j,refetchTrigger:Ue,showHistory:He,forcedDestinationTokenSymbol:Le,onSuccessfullySentTransaction:M,onFailedSentTransaction:b,onHistoryClose:D,onMvxConnect:oe,onMvxDisconnect:Oe,onNavigate:Ge,onChangeDirection:We})=>{var Ce,ve;const Xe=t.useRef(null),ce=t.useRef(void 0),[W,ze]=t.useState(!1),[E,I]=t.useState(!1),[Qe,$e]=t.useState(1),[X,z]=t.useState(0),q=Ds.useAccount(),{switchNetwork:le}=ys.useAppKitNetwork(),ue=Ts.useInvalidateHistoryQuery(),{config:de,options:me,supportedChains:C,nativeAuthToken:Q,bridgeOnly:Ke}=Ms.useWeb3App(),$=Rs.useGetChainId(),he=Es.useBridgeApiChainId(),{evmTokensWithBalances:Ye,mvxTokensWithBalances:Je,isTokensLoading:Ze,isLoadingEvmTokensBalances:es,isLoadingMvxTokensBalances:ss,chains:v=[],isChainsLoading:ts}=Fs.useFetchBridgeData({refetchTrigger:Ue,mvxAddress:c,mvxApiURL:me.mvxApiURL}),K=Ze||es||ss||ts,ns=t.useMemo(()=>C.find(n=>L.sameBridgeApiChainId(n.id,$)),[$,C]),o=t.useMemo(()=>v.find(n=>n.chainId.toString()===G.toString()),[$,v]),{evm:ge,solana:qe,bitcoin:pe,sui:fe}=Ps.useSignTransaction(),be=Vs.useSendTransactions(),{mutate:is,data:u,isPending:B,error:x}=Us.useGetRateMutation(),y=((Ce=x==null?void 0:x.response)==null?void 0:Ce.status)===400?(ve=x==null?void 0:x.response)==null?void 0:ve.data.message:void 0,rs=t.useCallback(n=>{const f=C.find(l=>L.sameBridgeApiChainId(l.id,n.id));f&&le(f)},[C,le]),{firstToken:e,secondToken:a,fromOptions:F,toOptions:as,selectedChainOption:r,onChangeFirstSelect:xe,onChangeSecondSelect:os,handleChangeDirection:cs}=Ss.useBridgeTokenSelection({chains:v,activeChain:ns,sdkChains:C,switchNetwork:rs,fromTokens:Ye,toTokens:Je,firstTokenIdentifier:Pe,secondTokenIdentifier:Te,forcedDestinationTokenSymbol:Le,isTokensLoading:K,callbackRoute:Ve,onNavigate:Ge}),ls=t.useMemo(()=>e?we.MVX_CHAIN_IDS.includes(e.chainId.toString()):!1,[e==null?void 0:e.chainId]),us=t.useMemo(()=>a?we.MVX_CHAIN_IDS.includes(a.chainId.toString()):!1,[a==null?void 0:a.chainId]),[m,ds]=t.useState(w??""),[R,V]=t.useState(j??""),d=t.useMemo(()=>e?v.find(n=>L.sameBridgeApiChainId(n.chainId,e.chainId))??r:r,[e==null?void 0:e.chainId,v,r]),P=t.useMemo(()=>L.toBridgeApiChainId(e==null?void 0:e.chainId)??he,[e==null?void 0:e.chainId,he]),Y=q.address,_e=q.isConnected&&!!Y,J=m!==""&&R!=="",Z=t.useCallback(ks(async n=>{!n||!Number(n)||!q.address||!(e!=null&&e.address)||!(a!=null&&a.address)||!r||!P||is({nativeAuthToken:Q??"",body:{tokenIn:e.address,amountIn:n,fromChainId:P,tokenOut:a.address,toChainId:G}})},500),[q.address,P,e==null?void 0:e.address,a==null?void 0:a.address,r]),h=t.useCallback(n=>{ds(()=>n)},[]),_=t.useCallback(n=>{V(()=>n)},[]),ms=t.useCallback(()=>{D==null||D()},[D]),hs=t.useCallback(()=>{const n=Bs.formatAmount({decimals:e==null?void 0:e.decimals,input:(e==null?void 0:e.balance)??"0",addCommas:!1,digits:4});p.setFieldValue("firstAmount",n),h(n)},[e==null?void 0:e.balance,e==null?void 0:e.decimals,h]),je=t.useCallback(async n=>{h(""),_(""),ue(),ue(),M==null||M(n)},[h,_,M]),gs=()=>{cs(),We()};t.useEffect(()=>{const n=ce.current;if(ce.current=r==null?void 0:r.chainId,!!n&&(r==null?void 0:r.chainId)!==(e==null?void 0:e.chainId)){const f=F==null?void 0:F.find(l=>l.chainId.toString()===(r==null?void 0:r.chainId));if(!f)return;xe(f)}},[r==null?void 0:r.chainId]);const qs=t.useCallback(async({transactions:n,provider:f})=>{var Be,ye,Ae;const l=[];I(!0),z(()=>n.length);try{let A=-1;for(const i of n){++A;try{switch(Ns.resolveSigningChainType(i,d)){case S.ChainType.evm:{const g=await ge.signTransaction({...i,value:BigInt(i.value),gas:BigInt(i.gasLimit),account:Y});if(!g||(l.push({...i,txHash:g}),A===n.length-1||!g))break;const U=await As.waitForTransactionReceipt(de,{confirmations:1,hash:g});console.info({transactionReceipt:U,hash:g});break}case S.ChainType.sol:if(!i.instructions||!i.feePayer)break;const ae=await qe.signTransaction({feePayer:i.feePayer,instructions:i.instructions,recentBlockhash:i.recentBlockhash});if(!ae)break;l.push({...i,txHash:ae});break;case S.ChainType.btc:if(!i.bitcoinParams){console.error("No bitcoin params");break}const Is=await pe.signTransaction(i.bitcoinParams);l.push({...i,txHash:Is});break;case S.ChainType.sui:{const g=(Be=i.suiParams)==null?void 0:Be.transactionBytes,U=(ye=i.suiParams)==null?void 0:ye.sender;if(!g||!U){console.error("No Sui transaction bytes or sender address");break}const Ne=await fe.signTransaction({transaction:g,address:U});if(!Ne)break;l.push({...i,suiParams:{...i.suiParams,signature:Ne}});break}default:k.toast.error("Provider not supported"),I(!1);return}z(()=>n.length-1-A)}catch{k.toast.dismiss(),k.toast.error("Transaction aborted"),b==null||b("Transaction aborted"),I(!1);return}}const{data:re}=await be({transactions:l,provider:f,url:ws.getApiURL()??"",token:Q??""}),ke=((Ae=re.transactions)==null?void 0:Ae.map(i=>i.txHash).filter(i=>!!i))??[],Se=l.map(i=>i.txHash).filter(i=>!!i),js=ke.length>0?ke:Se.length>0?Se:re.batchId?[re.batchId]:[];je(js),I(!1)}catch(A){console.error(A),k.toast.dismiss(),k.toast.error("Transaction cancelled"),b==null||b("Transaction cancelled"),I(!1),z(0),fs(),h(""),_("")}},[d==null?void 0:d.chainType,Y,de,h,_,Q,je,be,pe.signTransaction,ge.signTransaction,qe.signTransaction,fe.signTransaction]),{formik:p,firstAmountError:ee,secondAmountError:se,fromChainError:te,senderAddressError:ne,receiverAddressError:ie,handleBlur:T,handleChange:Ie,handleSubmit:ps,resetSwapForm:fs}=N.useBridgeFormik({isMvxConnected:!!c,rate:u,sender:q.address??"",receiver:c??"",firstToken:e,firstAmount:m,fromChainId:P,toChainId:G,secondToken:a,secondAmount:R,setForceRefetchRate:$e,senderChainType:d==null?void 0:d.chainType,receiverChainType:S.ChainType.mvx,onSubmit:qs}),bs=!!(ee||se||te||y||ne||ie),xs=t.useMemo(()=>m!==""?y??ee:void 0,[ee,m,y]),_s=t.useMemo(()=>R!==""?te??se:void 0,[te,se,R]);return t.useEffect(()=>(m||V(""),Z(m),O&&clearInterval(O),O=setInterval(()=>{Z(m)},50*1e3),()=>clearInterval(O)),[m,Qe,Z]),t.useEffect(()=>{u!=null&&u.amountOut&&(p.setFieldValue(N.BridgeFormikValuesEnum.secondAmount,u.amountOut),V(u.amountOut))},[u==null?void 0:u.amountOut]),t.useEffect(()=>{y&&(p.setFieldValue(N.BridgeFormikValuesEnum.secondAmount,"0"),V("0"))},[y]),t.useEffect(()=>{w&&(p.setFieldValue(N.BridgeFormikValuesEnum.firstAmount,w),h(w))},[]),t.useEffect(()=>{j&&(p.setFieldValue(N.BridgeFormikValuesEnum.secondAmount,j),_(j))},[j]),s.jsx(s.Fragment,{children:s.jsxs("form",{ref:Xe,noValidate:!0,className:"liq-flex liq-flex-col liq-gap-1 liq-relative",autoComplete:"off",onSubmit:ps,children:[He&&s.jsx(Ls.BridgeHistory,{mvxAddress:c,onClose:ms}),s.jsxs(De.AmountCard,{className:Me.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"From"}),s.jsx(Ws.BridgeAccountDisplay,{disabled:B,activeChain:d})]}),ne&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:ne}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Ee.AmountInput,{inputName:"firstAmount",inputValue:p.values.firstAmount,amountError:xs,disabled:!1,onInputDebounceChange:h,onInputChange:Ie,onBlur:T}),s.jsx(Fe.TokenSelector,{name:"firstToken",disabled:B,options:F,areOptionsLoading:K,isMvxSelector:ls,isDestination:!1,color:"neutral-850",onChange:xe,onBlur:T,onMaxBtnClick:hs,selectedOption:e,onTokenSelectorDisplay:n=>ze(n)})]})]}),s.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:Ke&&s.jsx(zs.ToggleDirection,{onChangeDirection:gs})}),s.jsxs(De.AmountCard,{className:Me.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"To"}),s.jsx(Xs.MvxAccountDisplay,{accountAddress:c,chainIcon:H.safeImageUrl(o==null?void 0:o.pngUrl),username:Re,accountExplorerUrl:`${me.mvxExplorerAddress}/accounts/${c}`,showTag:!0,onDisconnect:Oe,onConnect:oe})]}),ie&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:ie}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Ee.AmountInput,{inputName:"secondAmount",inputValue:p.values.secondAmount,amountError:_s,disabled:!1,onInputDebounceChange:_,onInputChange:Ie,onBlur:T}),s.jsx(Fe.TokenSelector,{name:"secondToken",disabled:B,omitDisableClass:!0,options:as,areOptionsLoading:K,isMvxSelector:us,color:"neutral-850",onChange:os,onBlur:T,selectedOption:a})]})]}),s.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!c&&s.jsx(Gs.MvxConnectButton,{mvxAccountAddress:c,icon:H.safeImageUrl(o==null?void 0:o.pngUrl),onClick:oe}),c&&!_e&&s.jsx(Os.BridgeConnectButton,{className:"liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",disabled:B,activeChain:d}),c&&_e&&s.jsxs(Hs.MxButton,{type:"submit",variant:"neutral-850",className:"liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",disabled:!J||B||!c||!q.address||bs||E,children:[J&&!E&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx("div",{children:"Deposit on "}),s.jsx("img",{src:H.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]}),!J&&!E&&s.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"}),E&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx(vs.FontAwesomeIcon,{icon:Cs.faSpinner,spin:!0,className:"liq-mx-1 liq-flex liq-items-center"}),s.jsx("div",{children:"Depositing on"}),s.jsx("img",{src:H.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]})]})]}),q.address&&X>0&&s.jsx("div",{className:"liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm",children:s.jsxs("div",{children:["You will be asked to sign ",X," ",X>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Deposit=Qs;
|