@xswap-link/sdk 0.12.1 → 0.12.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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.global.js +332 -336
- package/dist/index.js +33 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/TxConfigForm/index.tsx +8 -2
- package/src/components/TxWidgetWCWrapped/index.tsx +6 -0
- package/src/config/wagmiConfig.ts +2 -1
- package/src/context/SwapProvider.tsx +16 -14
- package/src/models/payloads/ModalIntegrationPayload.ts +2 -0
- package/src/models/payloads/WidgetIntegrationPayload.ts +2 -0
- package/src/services/integrations/transactions.ts +2 -0
- package/src/types/global.d.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -22167,15 +22167,20 @@ var SwapProvider = ({
|
|
|
22167
22167
|
setIsFetchingBalance(true);
|
|
22168
22168
|
let balance = "0";
|
|
22169
22169
|
if (srcChain?.ecosystem === "evm" /* EVM */ && evmAddress) {
|
|
22170
|
-
const
|
|
22171
|
-
|
|
22172
|
-
|
|
22173
|
-
|
|
22174
|
-
|
|
22175
|
-
|
|
22176
|
-
|
|
22177
|
-
|
|
22178
|
-
|
|
22170
|
+
const balanceFromBackend = tokenBalances[srcChain?.chainId]?.[srcToken.address];
|
|
22171
|
+
if (balanceFromBackend === void 0) {
|
|
22172
|
+
const balanceUI = await getBalanceOf(
|
|
22173
|
+
evmAddress,
|
|
22174
|
+
srcToken.address,
|
|
22175
|
+
srcChain?.publicRpcUrls[0]
|
|
22176
|
+
);
|
|
22177
|
+
balance = humanReadableToWei({
|
|
22178
|
+
amount: balanceUI,
|
|
22179
|
+
decimals: srcToken.decimals
|
|
22180
|
+
});
|
|
22181
|
+
} else {
|
|
22182
|
+
balance = balanceFromBackend;
|
|
22183
|
+
}
|
|
22179
22184
|
} else if (srcChain?.ecosystem === "solana" /* SOLANA */ && solanaAddress) {
|
|
22180
22185
|
const solanaPublicKey = new PublicKey4(solanaAddress);
|
|
22181
22186
|
const connection = new Connection2(srcChain.publicRpcUrls[0]);
|
|
@@ -22212,7 +22217,7 @@ var SwapProvider = ({
|
|
|
22212
22217
|
}
|
|
22213
22218
|
setSrcTokenBalanceWei(balance);
|
|
22214
22219
|
setIsFetchingBalance(false);
|
|
22215
|
-
}, [evmAddress, solanaAddress, srcChain, srcToken]);
|
|
22220
|
+
}, [evmAddress, solanaAddress, srcChain, srcToken, tokenBalances]);
|
|
22216
22221
|
const findTokenDataByAddressAndChain = useCallback6(
|
|
22217
22222
|
(tokenAddress, chainId) => {
|
|
22218
22223
|
return supportedTokens[chainId]?.[tokenAddress];
|
|
@@ -25153,7 +25158,7 @@ import { defineChain } from "viem";
|
|
|
25153
25158
|
import * as WagmiChains from "viem/chains";
|
|
25154
25159
|
import { mainnet } from "viem/chains";
|
|
25155
25160
|
import { createConfig, createStorage, http } from "@wagmi/core";
|
|
25156
|
-
import { walletConnect } from "@wagmi/connectors";
|
|
25161
|
+
import { injected, walletConnect } from "@wagmi/connectors";
|
|
25157
25162
|
var storage = createStorage({
|
|
25158
25163
|
key: "xpay.wagmi.store",
|
|
25159
25164
|
storage: !isServer ? localStorage : void 0
|
|
@@ -25165,6 +25170,7 @@ var getWagmiConfig = (supportedChains) => {
|
|
|
25165
25170
|
chains,
|
|
25166
25171
|
transports,
|
|
25167
25172
|
connectors: [
|
|
25173
|
+
injected(),
|
|
25168
25174
|
walletConnect({
|
|
25169
25175
|
projectId: "c392898b45ac587a280b5eb33e92aeb0",
|
|
25170
25176
|
showQrModal: true
|
|
@@ -28955,7 +28961,8 @@ var TxConfigForm = (props) => {
|
|
|
28955
28961
|
override,
|
|
28956
28962
|
integratorFee,
|
|
28957
28963
|
integratorFeeReceiverAddress,
|
|
28958
|
-
highlightedDstTokens
|
|
28964
|
+
highlightedDstTokens,
|
|
28965
|
+
wagmiConfig: providedWagmiConfig
|
|
28959
28966
|
} = normalizedProps;
|
|
28960
28967
|
const onBackdropClick = (e) => {
|
|
28961
28968
|
e.stopPropagation();
|
|
@@ -28965,8 +28972,8 @@ var TxConfigForm = (props) => {
|
|
|
28965
28972
|
}
|
|
28966
28973
|
};
|
|
28967
28974
|
const wagmiConfig = useMemo27(
|
|
28968
|
-
() => getWagmiConfig(supportedChains),
|
|
28969
|
-
[supportedChains]
|
|
28975
|
+
() => providedWagmiConfig ?? window.xPayWagmiConfig ?? getWagmiConfig(supportedChains),
|
|
28976
|
+
[providedWagmiConfig, supportedChains]
|
|
28970
28977
|
);
|
|
28971
28978
|
useEffect13(() => {
|
|
28972
28979
|
changeHostVariableColor(lightTheme, styles);
|
|
@@ -29056,7 +29063,8 @@ var openTxConfigForm = async ({
|
|
|
29056
29063
|
dstChainLocked,
|
|
29057
29064
|
srcTokenLocked,
|
|
29058
29065
|
srcChainLocked,
|
|
29059
|
-
override
|
|
29066
|
+
override,
|
|
29067
|
+
wagmiConfig
|
|
29060
29068
|
}) => {
|
|
29061
29069
|
try {
|
|
29062
29070
|
if (xpayRoot === null) {
|
|
@@ -29099,7 +29107,8 @@ var openTxConfigForm = async ({
|
|
|
29099
29107
|
dstChainLocked,
|
|
29100
29108
|
srcTokenLocked,
|
|
29101
29109
|
srcChainLocked,
|
|
29102
|
-
override
|
|
29110
|
+
override,
|
|
29111
|
+
wagmiConfig
|
|
29103
29112
|
}
|
|
29104
29113
|
)
|
|
29105
29114
|
);
|
|
@@ -29639,8 +29648,12 @@ var TxWidgetWCWrapped = ({
|
|
|
29639
29648
|
override,
|
|
29640
29649
|
integratorFee,
|
|
29641
29650
|
integratorFeeReceiverAddress,
|
|
29642
|
-
highlightedDstTokens
|
|
29651
|
+
highlightedDstTokens,
|
|
29652
|
+
wagmiConfig
|
|
29643
29653
|
}) => {
|
|
29654
|
+
if (typeof window !== "undefined") {
|
|
29655
|
+
window.xPayWagmiConfig = wagmiConfig;
|
|
29656
|
+
}
|
|
29644
29657
|
useEffect15(() => {
|
|
29645
29658
|
window.xPayOnPendingTransactionsChange = onPendingTransactionsChange;
|
|
29646
29659
|
window.xPayOnDstTokenChange = onDstTokenChange;
|
|
@@ -29879,7 +29892,8 @@ var openTransactionModal = async ({
|
|
|
29879
29892
|
onSrcTokenChange,
|
|
29880
29893
|
onSrcChainChange,
|
|
29881
29894
|
bridge,
|
|
29882
|
-
highlightedDstTokens
|
|
29895
|
+
highlightedDstTokens,
|
|
29896
|
+
wagmiConfig
|
|
29883
29897
|
}) => {
|
|
29884
29898
|
const supportedChains = (await getChains()).filter(
|
|
29885
29899
|
({ web3Environment, swapSupported, bridgeSupported }) => web3Environment === "mainnet" /* MAINNET */ && (swapSupported || bridgeSupported)
|
|
@@ -29915,7 +29929,8 @@ var openTransactionModal = async ({
|
|
|
29915
29929
|
onSrcTokenChange,
|
|
29916
29930
|
onSrcChainChange,
|
|
29917
29931
|
bridge,
|
|
29918
|
-
highlightedDstTokens
|
|
29932
|
+
highlightedDstTokens,
|
|
29933
|
+
wagmiConfig
|
|
29919
29934
|
});
|
|
29920
29935
|
};
|
|
29921
29936
|
var validateSwapTxData = (integratorId, supportedChains, dstChain, dstToken, srcChain, srcToken) => {
|