@multiversx/sdk-dapp-liquidity 1.1.0-alpha.2 → 1.1.0-alpha.21
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/README.md +6 -1
- package/api/getTransactions.d.ts +8 -2
- package/api/getTransactions.js +23 -3
- package/api/getTransactions.mjs +23 -3
- package/api/tests/getChains.spec.js +2 -1
- package/api/tests/getChains.spec.mjs +2 -1
- package/api/tests/getTokens.spec.js +2 -2
- package/api/tests/getTokens.spec.mjs +2 -2
- package/api/tests/getTransactions.spec.js +79 -69
- package/api/tests/getTransactions.spec.mjs +79 -69
- package/constants/index.d.ts +1 -1
- package/constants/index.js +1 -1
- package/constants/index.mjs +1 -1
- package/dto/Chain.dto.d.ts +3 -1
- package/dto/ConfirmRate.dto.d.ts +1 -0
- package/dto/Token.dto.d.ts +7 -2
- package/index.js +44 -16
- package/index.mjs +14 -16
- package/package.json +10 -6
- package/reactjs/components/BridgeForm/BridgeForm.d.ts +3 -1
- package/reactjs/components/BridgeForm/BridgeForm.js +182 -87
- package/reactjs/components/BridgeForm/BridgeForm.mjs +153 -58
- package/reactjs/components/BridgeHistory/BridgeHistory.js +73 -26
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +68 -21
- package/reactjs/components/Connect/BridgeAccountDisplay.js +2 -5
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +2 -5
- package/reactjs/components/Connect/CustomConnectButton.js +2 -5
- package/reactjs/components/Connect/CustomConnectButton.mjs +1 -4
- package/reactjs/components/Connect/MvxConnectButton.d.ts +2 -4
- package/reactjs/components/Connect/MvxConnectButton.js +2 -2
- package/reactjs/components/Connect/MvxConnectButton.mjs +2 -2
- package/reactjs/components/Connect/SwitchChainButton.js +2 -6
- package/reactjs/components/Connect/SwitchChainButton.mjs +1 -5
- package/reactjs/components/CopyButton/CopyButton.js +2 -2
- package/reactjs/components/CopyButton/CopyButton.mjs +2 -2
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.js +5 -5
- package/reactjs/components/Error/Error.d.ts +6 -0
- package/reactjs/components/Error/Error.js +67 -0
- package/reactjs/components/Error/Error.mjs +66 -0
- package/reactjs/components/Error/index.d.ts +1 -0
- package/reactjs/components/Error/index.js +5 -0
- package/reactjs/components/Error/index.mjs +4 -0
- package/reactjs/components/TokenSelector/TokenSelector.d.ts +2 -1
- package/reactjs/components/TokenSelector/TokenSelector.js +17 -9
- package/reactjs/components/TokenSelector/TokenSelector.mjs +13 -5
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.d.ts +2 -1
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +7 -3
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +4 -0
- package/reactjs/components/TokenSelector/components/SelectContent.d.ts +2 -1
- package/reactjs/components/TokenSelector/components/SelectContent.js +12 -9
- package/reactjs/components/TokenSelector/components/SelectContent.mjs +4 -1
- package/reactjs/components/TokenSelector/components/TokenIcon.js +3 -3
- package/reactjs/components/TokenSelector/components/TokenItem.js +9 -9
- package/reactjs/components/TokenSelector/components/TokenItem.mjs +6 -6
- package/reactjs/components/base/MxCard/MxCard.js +2 -2
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.d.ts +4 -0
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.js +29 -0
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.mjs +28 -0
- package/reactjs/components/base/MxCircleLoader/index.d.ts +1 -0
- package/reactjs/components/base/MxCircleLoader/index.js +5 -0
- package/reactjs/components/base/MxCircleLoader/index.mjs +4 -0
- package/reactjs/components/base/MxLink/MxLink.js +2 -2
- package/reactjs/components/base/MxSearch/MxSearch.js +4 -4
- package/reactjs/components/base/MxSlideover/MxSlideover.js +4 -4
- package/reactjs/components/base/MxTooltip/MxTooltip.js +9 -9
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.js +2 -2
- package/reactjs/components/index.d.ts +1 -0
- package/reactjs/components/index.js +2 -0
- package/reactjs/components/index.mjs +2 -0
- package/reactjs/context/Web3AppProvider.d.ts +3 -1
- package/reactjs/context/Web3AppProvider.js +7 -5
- package/reactjs/context/Web3AppProvider.mjs +4 -2
- package/reactjs/context/useWeb3App.js +2 -2
- package/reactjs/hooks/index.js +1 -1
- package/reactjs/hooks/index.mjs +1 -1
- package/reactjs/hooks/useAccount.js +1 -5
- package/reactjs/hooks/useAccount.mjs +1 -5
- package/reactjs/hooks/useBalances.d.ts +4 -4
- package/reactjs/hooks/useBalances.js +16 -1
- package/reactjs/hooks/useBalances.mjs +16 -1
- package/reactjs/hooks/useBridgeFormik.js +9 -16
- package/reactjs/hooks/useBridgeFormik.mjs +0 -7
- package/reactjs/hooks/useDebounce.js +3 -3
- package/reactjs/hooks/useFetchBridgeData.d.ts +14 -4
- package/reactjs/hooks/useFetchTokens.d.ts +14 -4
- package/reactjs/hooks/useFetchTokens.js +9 -9
- package/reactjs/hooks/useFetchTokens.mjs +2 -2
- package/reactjs/hooks/useFiatData.d.ts +7 -2
- package/reactjs/hooks/useFiatData.js +6 -6
- package/reactjs/hooks/useFiatData.mjs +1 -1
- package/reactjs/hooks/useGetChainId.js +3 -3
- package/reactjs/hooks/useGetChainId.mjs +1 -1
- package/reactjs/hooks/useResolveTokenChain.js +2 -2
- package/reactjs/hooks/useSendTransactions.js +2 -2
- package/reactjs/hooks/useSignTransaction.d.ts +93 -67
- package/reactjs/hooks/useSignTransaction.js +53 -4
- package/reactjs/hooks/useSignTransaction.mjs +53 -4
- package/reactjs/hooks/validation/useTestHasEnoughFunds.js +3 -3
- package/reactjs/hooks/validation/useTestIsConnected.js +2 -2
- package/reactjs/index.js +44 -16
- package/reactjs/index.mjs +14 -16
- package/reactjs/init/init.d.ts +220 -1
- package/reactjs/init/init.js +34 -10
- package/reactjs/init/init.mjs +31 -7
- package/reactjs/init/tests/init.spec.js +5 -6
- package/reactjs/init/tests/init.spec.mjs +5 -6
- package/reactjs/queries/index.d.ts +0 -1
- package/reactjs/queries/index.js +0 -2
- package/reactjs/queries/index.mjs +1 -3
- package/reactjs/queries/useGetEvmTokensBalances.query.d.ts +8 -3
- package/reactjs/queries/useGetEvmTokensBalances.query.js +15 -18
- package/reactjs/queries/useGetEvmTokensBalances.query.mjs +15 -18
- package/reactjs/queries/useGetHistory.query.d.ts +9 -1
- package/reactjs/queries/useGetHistory.query.js +23 -5
- package/reactjs/queries/useGetHistory.query.mjs +23 -5
- package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +7 -2
- package/reactjs/queries/useGetMvxTokensBalances.query.js +2 -2
- package/reactjs/reexports.d.ts +2 -1
- package/reactjs/reexports.js +41 -13
- package/reactjs/reexports.mjs +11 -13
- package/reactjs/utils/getInitialTokens.d.ts +4 -1
- package/reactjs/utils/getInitialTokens.js +3 -3
- package/reactjs/utils/getInitialTokens.mjs +3 -3
- package/style.css +33 -1730
- package/types/chainType.d.ts +6 -0
- package/types/chainType.js +11 -0
- package/types/chainType.mjs +10 -0
- package/types/transaction.d.ts +28 -0
- package/types/utxo.d.ts +11 -0
- package/types/utxo.js +2 -0
- package/types/utxo.mjs +1 -0
- package/{useBalances-C_69CFoa.mjs → useBalances-Bom1mw1J.mjs} +101 -23
- package/{useBalances-C4YhEYxy.js → useBalances-gZTsFZHe.js} +102 -24
- package/index-BIVnypNe.mjs +0 -108
- package/index-Ben8n3bd.js +0 -58656
- package/index-CnKr4rL1.mjs +0 -91
- package/index-CnuruJNu.js +0 -329
- package/index-DsBh-EBw.js +0 -108
- package/index-iN9APQ6x.mjs +0 -58735
- package/modules/fiat/components/FiatForm/FiatForm.d.ts +0 -9
- package/modules/fiat/components/FiatForm/FiatForm.js +0 -314
- package/modules/fiat/components/FiatForm/FiatForm.mjs +0 -313
- package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.d.ts +0 -13
- package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.js +0 -117
- package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.mjs +0 -116
- package/modules/fiat/components/FiatForm/components/AmountInput/index.d.ts +0 -1
- package/modules/fiat/components/FiatForm/components/AmountInput/index.js +0 -5
- package/modules/fiat/components/FiatForm/components/AmountInput/index.mjs +0 -4
- package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.js +0 -74
- package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.mjs +0 -73
- package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.d.ts +0 -14
- package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.js +0 -94
- package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.mjs +0 -93
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.js +0 -82
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.mjs +0 -81
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.js +0 -91
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.mjs +0 -90
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.d.ts +0 -5
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.js +0 -30
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.mjs +0 -29
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.d.ts +0 -8
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.js +0 -103
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.mjs +0 -102
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.js +0 -33
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.mjs +0 -32
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.js +0 -21
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.mjs +0 -20
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.d.ts +0 -9
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.js +0 -26
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.mjs +0 -25
- package/modules/fiat/components/FiatForm/components/TokenSelector/index.d.ts +0 -1
- package/modules/fiat/components/FiatForm/components/TokenSelector/index.js +0 -5
- package/modules/fiat/components/FiatForm/components/TokenSelector/index.mjs +0 -4
- package/modules/fiat/components/FiatForm/index.d.ts +0 -1
- package/modules/fiat/components/FiatForm/index.js +0 -5
- package/modules/fiat/components/FiatForm/index.mjs +0 -4
- package/modules/fiat/components/index.d.ts +0 -1
- package/modules/fiat/components/index.js +0 -5
- package/modules/fiat/components/index.mjs +0 -4
- package/modules/fiat/context/FiatProvider.d.ts +0 -8
- package/modules/fiat/context/FiatProvider.js +0 -24
- package/modules/fiat/context/FiatProvider.mjs +0 -23
- package/modules/fiat/context/queryClient.d.ts +0 -3
- package/modules/fiat/context/queryClient.js +0 -12
- package/modules/fiat/context/queryClient.mjs +0 -11
- package/modules/fiat/context/useFiat.d.ts +0 -1
- package/modules/fiat/context/useFiat.js +0 -13
- package/modules/fiat/context/useFiat.mjs +0 -12
- package/modules/fiat/hooks/index.d.ts +0 -2
- package/modules/fiat/hooks/index.js +0 -7
- package/modules/fiat/hooks/index.mjs +0 -6
- package/modules/fiat/hooks/useFiatData.d.ts +0 -7
- package/modules/fiat/hooks/useFiatData.js +0 -75
- package/modules/fiat/hooks/useFiatData.mjs +0 -74
- package/modules/fiat/hooks/validation/index.d.ts +0 -1
- package/modules/fiat/hooks/validation/index.js +0 -5
- package/modules/fiat/hooks/validation/index.mjs +0 -4
- package/modules/fiat/hooks/validation/useAmountSchema.d.ts +0 -2
- package/modules/fiat/hooks/validation/useAmountSchema.js +0 -27
- package/modules/fiat/hooks/validation/useAmountSchema.mjs +0 -9
- package/modules/fiat/index.d.ts +0 -8
- package/modules/fiat/index.js +0 -22
- package/modules/fiat/index.mjs +0 -21
- package/modules/fiat/init/index.d.ts +0 -2
- package/modules/fiat/init/index.js +0 -5
- package/modules/fiat/init/index.mjs +0 -4
- package/modules/fiat/init/init.d.ts +0 -22
- package/modules/fiat/init/init.js +0 -15
- package/modules/fiat/init/init.mjs +0 -14
- package/modules/fiat/queries/index.d.ts +0 -2
- package/modules/fiat/queries/index.js +0 -7
- package/modules/fiat/queries/index.mjs +0 -6
- package/modules/fiat/queries/useGetRate.mutation.d.ts +0 -6
- package/modules/fiat/queries/useGetRate.mutation.js +0 -20
- package/modules/fiat/queries/useGetRate.mutation.mjs +0 -19
- package/modules/fiat/queries/useGetTokens.query.d.ts +0 -5
- package/modules/fiat/queries/useGetTokens.query.js +0 -33
- package/modules/fiat/queries/useGetTokens.query.mjs +0 -32
- package/react-47kZTyAT.mjs +0 -51
- package/react-B_iI3-1z.mjs +0 -3133
- package/react-BomcNL1v.js +0 -254
- package/react-CqKlu0W0.js +0 -51
- package/react-R_xxu7fN.js +0 -3133
- package/react-cXurUY4Z.mjs +0 -254
- package/reactjs/queries/useGetTokens.query.d.ts +0 -3
- package/reactjs/queries/useGetTokens.query.js +0 -34
- package/reactjs/queries/useGetTokens.query.mjs +0 -33
- package/w3m-modal-Bhg44d6I.js +0 -356
- package/w3m-modal-Br2Ec3MM.mjs +0 -356
|
@@ -6,10 +6,10 @@ const faSpinner = require("@fortawesome/free-solid-svg-icons/faSpinner");
|
|
|
6
6
|
const reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
7
7
|
const formatAmount = require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
|
|
8
8
|
const debounce = require("lodash/debounce");
|
|
9
|
-
const
|
|
9
|
+
const React = require("react");
|
|
10
10
|
const reactToastify = require("react-toastify");
|
|
11
|
-
const wagmi = require("wagmi");
|
|
12
11
|
const helpers_getApiURL = require("../../../helpers/getApiURL.js");
|
|
12
|
+
const types_chainType = require("../../../types/chainType.js");
|
|
13
13
|
const reactjs_constants_index = require("../../constants/index.js");
|
|
14
14
|
const reactjs_context_useWeb3App = require("../../context/useWeb3App.js");
|
|
15
15
|
const reactjs_hooks_useAccount = require("../../hooks/useAccount.js");
|
|
@@ -36,15 +36,15 @@ require("react-popper");
|
|
|
36
36
|
require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");
|
|
37
37
|
const reactjs_components_BridgeHistory_BridgeHistory = require("../BridgeHistory/BridgeHistory.js");
|
|
38
38
|
const reactjs_components_Connect_BridgeConnectButton = require("../Connect/BridgeConnectButton.js");
|
|
39
|
-
require("
|
|
40
|
-
|
|
41
|
-
require("viem/chains");
|
|
39
|
+
require("@reown/appkit/react");
|
|
40
|
+
require("wagmi");
|
|
42
41
|
const reactjs_components_Connect_MvxConnectButton = require("../Connect/MvxConnectButton.js");
|
|
43
42
|
const reactjs_components_Connect_BridgeAccountDisplay = require("../Connect/BridgeAccountDisplay.js");
|
|
44
43
|
const reactjs_components_Connect_MvxAccountDisplay = require("../Connect/MvxAccountDisplay.js");
|
|
45
44
|
const reactjs_components_TokenSelector_TokenSelector = require("../TokenSelector/TokenSelector.js");
|
|
45
|
+
const viem = require("viem");
|
|
46
46
|
const actions = require("viem/actions");
|
|
47
|
-
const reactjs_hooks_useBalances = require("../../../useBalances-
|
|
47
|
+
const reactjs_hooks_useBalances = require("../../../useBalances-gZTsFZHe.js");
|
|
48
48
|
function deepEqual(a, b) {
|
|
49
49
|
if (a === b)
|
|
50
50
|
return true;
|
|
@@ -123,6 +123,8 @@ const BridgeForm = ({
|
|
|
123
123
|
username,
|
|
124
124
|
nativeAuthToken,
|
|
125
125
|
callbackRoute = "/",
|
|
126
|
+
firstTokenIdentifier,
|
|
127
|
+
secondTokenIdentifier,
|
|
126
128
|
refetchTrigger,
|
|
127
129
|
showHistory,
|
|
128
130
|
onSuccessfullySentTransaction,
|
|
@@ -133,13 +135,13 @@ const BridgeForm = ({
|
|
|
133
135
|
onNavigate
|
|
134
136
|
}) => {
|
|
135
137
|
var _a, _b, _c, _d, _e, _f;
|
|
136
|
-
const ref =
|
|
137
|
-
const
|
|
138
|
-
const [
|
|
139
|
-
const [
|
|
138
|
+
const ref = React.useRef(null);
|
|
139
|
+
const initializedInitialTokensRef = React.useRef(false);
|
|
140
|
+
const [isTokenSelectorVisible, setIsTokenSelectorVisible] = React.useState(false);
|
|
141
|
+
const [pendingSigning, setPendingSigning] = React.useState(false);
|
|
142
|
+
const [siginingTransactionsCount, setSigningTransactionsCount] = React.useState(0);
|
|
140
143
|
const account = reactjs_hooks_useAccount.useAccount();
|
|
141
|
-
const {
|
|
142
|
-
const { config, options } = reactjs_context_useWeb3App.useWeb3App();
|
|
144
|
+
const { config, options, supportedChains: sdkChains } = reactjs_context_useWeb3App.useWeb3App();
|
|
143
145
|
const chainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
144
146
|
const {
|
|
145
147
|
evmTokensWithBalances,
|
|
@@ -155,17 +157,17 @@ const BridgeForm = ({
|
|
|
155
157
|
mvxApiURL: options.mvxApiURL
|
|
156
158
|
});
|
|
157
159
|
const isTokensLoading = tokensLoading || isLoadingEvmTokensBalances || isLoadingMvxTokensBalances || isChainsLoading;
|
|
158
|
-
const activeChain =
|
|
160
|
+
const activeChain = React.useMemo(() => {
|
|
159
161
|
return sdkChains.find(
|
|
160
162
|
(chain) => chain.id.toString() === (chainId == null ? void 0 : chainId.toString())
|
|
161
163
|
);
|
|
162
164
|
}, [chainId, sdkChains]);
|
|
163
|
-
const mvxChain =
|
|
165
|
+
const mvxChain = React.useMemo(() => {
|
|
164
166
|
return chains.find(
|
|
165
167
|
(chain) => chain.chainId.toString() === mvxChainId.toString()
|
|
166
168
|
);
|
|
167
169
|
}, [chainId, chains]);
|
|
168
|
-
const {
|
|
170
|
+
const { evm, solana, bitcoin } = reactjs_hooks_useSignTransaction.useSignTransaction();
|
|
169
171
|
const sendTransactions = reactjs_hooks_useSendTransactions.useSendTransactions();
|
|
170
172
|
const {
|
|
171
173
|
mutate: getRate,
|
|
@@ -174,13 +176,13 @@ const BridgeForm = ({
|
|
|
174
176
|
error: rateError
|
|
175
177
|
} = reactjs_queries_useGetRate_mutation.useGetRateMutation();
|
|
176
178
|
const rateValidationError = ((_a = rateError == null ? void 0 : rateError.response) == null ? void 0 : _a.status) === 400 ? (_b = rateError == null ? void 0 : rateError.response) == null ? void 0 : _b.data.message : void 0;
|
|
177
|
-
const [firstToken, setFirstToken] =
|
|
178
|
-
const [firstAmount, setFirstAmount] =
|
|
179
|
-
const [secondToken, setSecondToken] =
|
|
180
|
-
const [secondAmount, setSecondAmount] =
|
|
179
|
+
const [firstToken, setFirstToken] = React.useState();
|
|
180
|
+
const [firstAmount, setFirstAmount] = React.useState("");
|
|
181
|
+
const [secondToken, setSecondToken] = React.useState();
|
|
182
|
+
const [secondAmount, setSecondAmount] = React.useState("");
|
|
181
183
|
const bridgeAddress = account.address;
|
|
182
184
|
const isAuthenticated = account.isConnected && Boolean(bridgeAddress);
|
|
183
|
-
const fromOptions =
|
|
185
|
+
const fromOptions = React.useMemo(
|
|
184
186
|
() => (evmTokensWithBalances && evmTokensWithBalances.map((token) => {
|
|
185
187
|
return {
|
|
186
188
|
...token,
|
|
@@ -190,28 +192,48 @@ const BridgeForm = ({
|
|
|
190
192
|
})) ?? [],
|
|
191
193
|
[evmTokensWithBalances]
|
|
192
194
|
);
|
|
193
|
-
const
|
|
194
|
-
() =>
|
|
195
|
+
const getAvailableTokens = React.useCallback(
|
|
196
|
+
(option) => {
|
|
197
|
+
if (!(option == null ? void 0 : option.availableTokens)) {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
const foundTokens = [];
|
|
201
|
+
for (const availableToken of option.availableTokens) {
|
|
202
|
+
const foundToken = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
203
|
+
(mvxToken) => mvxToken.address === availableToken.address
|
|
204
|
+
);
|
|
205
|
+
if (foundToken) {
|
|
206
|
+
foundTokens.push(foundToken);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return foundTokens;
|
|
210
|
+
},
|
|
211
|
+
[mvxTokensWithBalances]
|
|
212
|
+
);
|
|
213
|
+
const toOptions = React.useMemo(
|
|
214
|
+
() => ((firstToken == null ? void 0 : firstToken.availableTokens) && getAvailableTokens(firstToken).map((token) => {
|
|
195
215
|
return {
|
|
196
216
|
...token,
|
|
197
217
|
identifier: token.address,
|
|
198
218
|
ticker: token.symbol
|
|
199
219
|
};
|
|
200
220
|
})) ?? [],
|
|
201
|
-
[
|
|
221
|
+
[firstToken == null ? void 0 : firstToken.availableTokens]
|
|
202
222
|
);
|
|
203
|
-
const selectedChainOption =
|
|
223
|
+
const selectedChainOption = React.useMemo(
|
|
204
224
|
() => (chains == null ? void 0 : chains.find(
|
|
205
225
|
(option) => option.chainId.toString() === (activeChain == null ? void 0 : activeChain.id.toString())
|
|
206
226
|
)) ?? (chains == null ? void 0 : chains[0]),
|
|
207
227
|
[activeChain == null ? void 0 : activeChain.id, chains]
|
|
208
228
|
);
|
|
209
|
-
const
|
|
210
|
-
() =>
|
|
211
|
-
|
|
229
|
+
const getDefaultReceivingToken = React.useCallback(
|
|
230
|
+
(values) => values.find((x) => x.symbol.toLowerCase().includes("usdc")) ?? (mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
231
|
+
(x) => x.symbol.toLowerCase().includes("usdc")
|
|
232
|
+
)),
|
|
233
|
+
[mvxTokensWithBalances]
|
|
212
234
|
);
|
|
213
235
|
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
214
|
-
const fetchRateDebounced =
|
|
236
|
+
const fetchRateDebounced = React.useCallback(
|
|
215
237
|
debounce(async (amount) => {
|
|
216
238
|
if (!amount || !account.address || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !selectedChainOption || !chainId) {
|
|
217
239
|
return;
|
|
@@ -234,18 +256,18 @@ const BridgeForm = ({
|
|
|
234
256
|
selectedChainOption
|
|
235
257
|
]
|
|
236
258
|
);
|
|
237
|
-
const handleOnChangeFirstAmount =
|
|
259
|
+
const handleOnChangeFirstAmount = React.useCallback((amount) => {
|
|
238
260
|
setFirstAmount(() => amount);
|
|
239
261
|
setLastChangedField(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.firstAmount);
|
|
240
262
|
}, []);
|
|
241
|
-
const handleOnChangeSecondAmount =
|
|
263
|
+
const handleOnChangeSecondAmount = React.useCallback((amount) => {
|
|
242
264
|
setSecondAmount(() => amount);
|
|
243
265
|
setLastChangedField(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount);
|
|
244
266
|
}, []);
|
|
245
|
-
const handleHistoryClose =
|
|
267
|
+
const handleHistoryClose = React.useCallback(() => {
|
|
246
268
|
onHistoryClose == null ? void 0 : onHistoryClose();
|
|
247
269
|
}, [onHistoryClose]);
|
|
248
|
-
const handleOnFirstMaxBtnChange =
|
|
270
|
+
const handleOnFirstMaxBtnChange = React.useCallback(() => {
|
|
249
271
|
const formattedBalance = formatAmount.formatAmount({
|
|
250
272
|
decimals: firstToken == null ? void 0 : firstToken.decimals,
|
|
251
273
|
input: (firstToken == null ? void 0 : firstToken.balance) ?? "0",
|
|
@@ -255,7 +277,7 @@ const BridgeForm = ({
|
|
|
255
277
|
formik.setFieldValue("firstAmount", formattedBalance);
|
|
256
278
|
handleOnChangeFirstAmount(formattedBalance);
|
|
257
279
|
}, [firstToken == null ? void 0 : firstToken.balance, firstToken == null ? void 0 : firstToken.decimals, handleOnChangeFirstAmount]);
|
|
258
|
-
const onSuccess =
|
|
280
|
+
const onSuccess = React.useCallback(
|
|
259
281
|
async (txHashes) => {
|
|
260
282
|
handleOnChangeFirstAmount("");
|
|
261
283
|
handleOnChangeSecondAmount("");
|
|
@@ -269,9 +291,9 @@ const BridgeForm = ({
|
|
|
269
291
|
onSuccessfullySentTransaction
|
|
270
292
|
]
|
|
271
293
|
);
|
|
272
|
-
const updateUrlParams =
|
|
294
|
+
const updateUrlParams = React.useCallback(
|
|
273
295
|
({ firstTokenId, secondTokenId }) => {
|
|
274
|
-
if (isTokensLoading
|
|
296
|
+
if (isTokensLoading) {
|
|
275
297
|
return;
|
|
276
298
|
}
|
|
277
299
|
const currentUrl = reactjs_utils_getCompletePathname.getCompletePathname();
|
|
@@ -288,18 +310,28 @@ const BridgeForm = ({
|
|
|
288
310
|
}
|
|
289
311
|
onNavigate == null ? void 0 : onNavigate(newUrl, { replace: true });
|
|
290
312
|
},
|
|
291
|
-
[
|
|
313
|
+
[callbackRoute, isTokensLoading, onNavigate]
|
|
292
314
|
);
|
|
293
|
-
|
|
315
|
+
console.log("BridgeForm", {
|
|
316
|
+
firstToken,
|
|
317
|
+
secondToken,
|
|
318
|
+
fromOptions,
|
|
319
|
+
toOptions
|
|
320
|
+
});
|
|
321
|
+
const onChangeFirstSelect = React.useCallback(
|
|
294
322
|
(option) => {
|
|
295
323
|
if (!option) {
|
|
296
324
|
return;
|
|
297
325
|
}
|
|
298
326
|
setFirstToken(() => option);
|
|
299
327
|
updateUrlParams({ firstTokenId: option == null ? void 0 : option.address });
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
328
|
+
const availableTokens = getAvailableTokens(option);
|
|
329
|
+
const secondOption = availableTokens.find(
|
|
330
|
+
(x) => {
|
|
331
|
+
var _a2;
|
|
332
|
+
return x.symbol.toLowerCase() === ((_a2 = availableTokens == null ? void 0 : availableTokens[0]) == null ? void 0 : _a2.symbol.toLowerCase());
|
|
333
|
+
}
|
|
334
|
+
) ?? getDefaultReceivingToken(availableTokens);
|
|
303
335
|
if (!secondOption) {
|
|
304
336
|
return;
|
|
305
337
|
}
|
|
@@ -308,7 +340,7 @@ const BridgeForm = ({
|
|
|
308
340
|
},
|
|
309
341
|
[toOptions, updateUrlParams]
|
|
310
342
|
);
|
|
311
|
-
const onChangeSecondSelect =
|
|
343
|
+
const onChangeSecondSelect = React.useCallback(
|
|
312
344
|
(option) => {
|
|
313
345
|
if (!option) {
|
|
314
346
|
return;
|
|
@@ -328,10 +360,13 @@ const BridgeForm = ({
|
|
|
328
360
|
);
|
|
329
361
|
const setInitialSelectedTokens = () => {
|
|
330
362
|
var _a2, _b2, _c2, _d2;
|
|
331
|
-
if (isTokensLoading) {
|
|
363
|
+
if (isTokensLoading || initializedInitialTokensRef.current) {
|
|
332
364
|
return;
|
|
333
365
|
}
|
|
334
|
-
const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens(
|
|
366
|
+
const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens({
|
|
367
|
+
firstTokenId: firstTokenIdentifier,
|
|
368
|
+
secondTokenId: secondTokenIdentifier
|
|
369
|
+
});
|
|
335
370
|
const firstOption = (fromOptions == null ? void 0 : fromOptions.find(
|
|
336
371
|
({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
|
|
337
372
|
)) ?? fromOptions.find(
|
|
@@ -339,27 +374,39 @@ const BridgeForm = ({
|
|
|
339
374
|
var _a3;
|
|
340
375
|
return option.chainId.toString() === ((_a3 = activeChain == null ? void 0 : activeChain.id) == null ? void 0 : _a3.toString());
|
|
341
376
|
}
|
|
342
|
-
);
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
377
|
+
) ?? (fromOptions == null ? void 0 : fromOptions[0]);
|
|
378
|
+
const availableTokens = getAvailableTokens(firstOption);
|
|
379
|
+
const secondOption = (availableTokens == null ? void 0 : availableTokens.find(
|
|
380
|
+
({ address }) => {
|
|
381
|
+
var _a3;
|
|
382
|
+
return address.toLowerCase() === ((_a3 = (firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)) == null ? void 0 : _a3.toLowerCase());
|
|
383
|
+
}
|
|
384
|
+
)) ?? availableTokens.find(
|
|
346
385
|
(x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
|
|
347
|
-
) ??
|
|
386
|
+
) ?? getDefaultReceivingToken(availableTokens);
|
|
348
387
|
const hasOptionsSelected = Boolean(firstToken) && Boolean(secondToken) && ((_a2 = firstToken == null ? void 0 : firstToken.address) == null ? void 0 : _a2.toLowerCase()) === ((_b2 = firstOption == null ? void 0 : firstOption.address) == null ? void 0 : _b2.toLowerCase()) && ((_c2 = secondToken == null ? void 0 : secondToken.address) == null ? void 0 : _c2.toLowerCase()) === ((_d2 = secondOption == null ? void 0 : secondOption.address) == null ? void 0 : _d2.toLowerCase());
|
|
349
388
|
if (hasOptionsSelected) {
|
|
350
389
|
return;
|
|
351
390
|
}
|
|
352
|
-
|
|
353
|
-
|
|
391
|
+
let initializedFirstToken = false;
|
|
392
|
+
if (firstOption) {
|
|
393
|
+
setFirstToken(firstOption);
|
|
394
|
+
updateUrlParams({
|
|
395
|
+
firstTokenId: firstOption == null ? void 0 : firstOption.address
|
|
396
|
+
});
|
|
397
|
+
initializedFirstToken = true;
|
|
354
398
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
399
|
+
let initializedSecondToken = false;
|
|
400
|
+
if (secondOption) {
|
|
401
|
+
setSecondToken(secondOption);
|
|
402
|
+
updateUrlParams({
|
|
403
|
+
secondTokenId: secondOption == null ? void 0 : secondOption.address
|
|
404
|
+
});
|
|
405
|
+
initializedSecondToken = true;
|
|
406
|
+
}
|
|
407
|
+
initializedInitialTokensRef.current = initializedFirstToken && initializedSecondToken;
|
|
361
408
|
};
|
|
362
|
-
const onSubmit =
|
|
409
|
+
const onSubmit = React.useCallback(
|
|
363
410
|
async ({
|
|
364
411
|
transactions,
|
|
365
412
|
provider
|
|
@@ -372,30 +419,76 @@ const BridgeForm = ({
|
|
|
372
419
|
for (const transaction of transactions) {
|
|
373
420
|
++txIndex;
|
|
374
421
|
try {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
422
|
+
switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
|
|
423
|
+
case types_chainType.ChainType.evm:
|
|
424
|
+
const hash = await evm.signTransaction({
|
|
425
|
+
...transaction,
|
|
426
|
+
value: BigInt(transaction.value),
|
|
427
|
+
gas: BigInt(transaction.gasLimit),
|
|
428
|
+
account: bridgeAddress
|
|
429
|
+
});
|
|
430
|
+
if (!hash) {
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
signedTransactions.push({
|
|
434
|
+
...transaction,
|
|
435
|
+
txHash: hash
|
|
436
|
+
});
|
|
437
|
+
if (txIndex === transactions.length - 1 || !hash) {
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
const transactionReceipt = await waitForTransactionReceipt(
|
|
441
|
+
config,
|
|
442
|
+
{
|
|
443
|
+
confirmations: 1,
|
|
444
|
+
hash
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
console.info({
|
|
448
|
+
transactionReceipt,
|
|
449
|
+
hash
|
|
450
|
+
});
|
|
451
|
+
break;
|
|
452
|
+
case types_chainType.ChainType.sol:
|
|
453
|
+
if (!transaction.instructions || !transaction.feePayer) {
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
const txHash = await solana.signTransaction({
|
|
457
|
+
feePayer: transaction.feePayer,
|
|
458
|
+
instructions: transaction.instructions
|
|
459
|
+
});
|
|
460
|
+
if (!txHash) {
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
signedTransactions.push({
|
|
464
|
+
...transaction,
|
|
465
|
+
txHash
|
|
466
|
+
});
|
|
467
|
+
break;
|
|
468
|
+
case types_chainType.ChainType.btc:
|
|
469
|
+
if (!transaction.bitcoinParams) {
|
|
470
|
+
console.error("No bitcoin params");
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
console.log({
|
|
474
|
+
transaction
|
|
475
|
+
});
|
|
476
|
+
const psbt = await bitcoin.signTransaction(
|
|
477
|
+
transaction.bitcoinParams
|
|
478
|
+
);
|
|
479
|
+
signedTransactions.push({
|
|
480
|
+
...transaction,
|
|
481
|
+
txHash: psbt
|
|
482
|
+
});
|
|
483
|
+
break;
|
|
484
|
+
default:
|
|
485
|
+
reactToastify.toast.error("Provider not supported");
|
|
486
|
+
setPendingSigning(false);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
385
489
|
setSigningTransactionsCount(
|
|
386
490
|
() => transactions.length - 1 - txIndex
|
|
387
491
|
);
|
|
388
|
-
if (txIndex === transactions.length - 1) {
|
|
389
|
-
continue;
|
|
390
|
-
}
|
|
391
|
-
const transactionReceipt = await waitForTransactionReceipt(config, {
|
|
392
|
-
confirmations: 1,
|
|
393
|
-
hash: txHash
|
|
394
|
-
});
|
|
395
|
-
console.info({
|
|
396
|
-
transactionReceipt,
|
|
397
|
-
hash: txHash
|
|
398
|
-
});
|
|
399
492
|
} catch (e) {
|
|
400
493
|
reactToastify.toast.dismiss();
|
|
401
494
|
reactToastify.toast.error("Transaction aborted");
|
|
@@ -432,7 +525,7 @@ const BridgeForm = ({
|
|
|
432
525
|
nativeAuthToken,
|
|
433
526
|
onSuccess,
|
|
434
527
|
sendTransactions,
|
|
435
|
-
signTransaction
|
|
528
|
+
evm.signTransaction
|
|
436
529
|
]
|
|
437
530
|
);
|
|
438
531
|
const {
|
|
@@ -460,7 +553,7 @@ const BridgeForm = ({
|
|
|
460
553
|
const hasError = Boolean(
|
|
461
554
|
firstAmountError || secondAmountError || fromChainError || rateValidationError
|
|
462
555
|
);
|
|
463
|
-
|
|
556
|
+
React.useEffect(() => {
|
|
464
557
|
if (!firstAmount) {
|
|
465
558
|
setSecondAmount("");
|
|
466
559
|
}
|
|
@@ -473,21 +566,21 @@ const BridgeForm = ({
|
|
|
473
566
|
}, 60 * 1e3);
|
|
474
567
|
return () => clearInterval(fetchRateInterval);
|
|
475
568
|
}, [firstAmount, fetchRateDebounced]);
|
|
476
|
-
|
|
569
|
+
React.useEffect(() => {
|
|
477
570
|
if (!(rate == null ? void 0 : rate.amountOut)) {
|
|
478
571
|
return;
|
|
479
572
|
}
|
|
480
573
|
formik.setFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, rate.amountOut);
|
|
481
574
|
setSecondAmount(rate.amountOut);
|
|
482
575
|
}, [rate == null ? void 0 : rate.amountOut]);
|
|
483
|
-
|
|
576
|
+
React.useEffect(() => {
|
|
484
577
|
if (rateValidationError) {
|
|
485
578
|
formik.setFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, "0");
|
|
486
579
|
setSecondAmount("0");
|
|
487
580
|
}
|
|
488
581
|
}, [rateValidationError]);
|
|
489
|
-
|
|
490
|
-
|
|
582
|
+
React.useEffect(setInitialSelectedTokens, [isTokensLoading, fromOptions]);
|
|
583
|
+
React.useEffect(() => {
|
|
491
584
|
const selectedTokenOption = evmTokensWithBalances == null ? void 0 : evmTokensWithBalances.find(
|
|
492
585
|
(x) => x.address === (firstToken == null ? void 0 : firstToken.address)
|
|
493
586
|
);
|
|
@@ -504,7 +597,7 @@ const BridgeForm = ({
|
|
|
504
597
|
};
|
|
505
598
|
});
|
|
506
599
|
}, [evmTokensWithBalances, firstToken == null ? void 0 : firstToken.address]);
|
|
507
|
-
|
|
600
|
+
React.useEffect(() => {
|
|
508
601
|
const selectedTokenOption = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
509
602
|
(x) => x.address === (secondToken == null ? void 0 : secondToken.address)
|
|
510
603
|
);
|
|
@@ -572,6 +665,7 @@ const BridgeForm = ({
|
|
|
572
665
|
disabled: isPendingRate,
|
|
573
666
|
options: fromOptions,
|
|
574
667
|
areOptionsLoading: isTokensLoading,
|
|
668
|
+
isMvxSelector: false,
|
|
575
669
|
color: "neutral-850",
|
|
576
670
|
onChange: onChangeFirstSelect,
|
|
577
671
|
onBlur: handleBlur,
|
|
@@ -626,10 +720,11 @@ const BridgeForm = ({
|
|
|
626
720
|
reactjs_components_TokenSelector_TokenSelector.TokenSelector,
|
|
627
721
|
{
|
|
628
722
|
name: "secondToken",
|
|
629
|
-
disabled:
|
|
723
|
+
disabled: isPendingRate,
|
|
630
724
|
omitDisableClass: true,
|
|
631
725
|
options: toOptions,
|
|
632
726
|
areOptionsLoading: isTokensLoading,
|
|
727
|
+
isMvxSelector: true,
|
|
633
728
|
color: "neutral-850",
|
|
634
729
|
onChange: onChangeSecondSelect,
|
|
635
730
|
onBlur: handleBlur,
|
|
@@ -645,7 +740,7 @@ const BridgeForm = ({
|
|
|
645
740
|
reactjs_components_Connect_MvxConnectButton.MvxConnectButton,
|
|
646
741
|
{
|
|
647
742
|
mvxAccountAddress: mvxAddress,
|
|
648
|
-
|
|
743
|
+
icon: mvxChain == null ? void 0 : mvxChain.svgUrl,
|
|
649
744
|
onClick: onMvxConnect
|
|
650
745
|
}
|
|
651
746
|
),
|