@skip-go/widget 2.3.8 → 2.4.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/README.md +2 -193
- package/build/hooks/use-assets.d.ts +3 -4
- package/build/hooks/use-auto-set-address.d.ts +2 -1
- package/build/hooks/use-balances-by-chain.d.ts +4 -3
- package/build/hooks/use-bridges.d.ts +3 -2
- package/build/hooks/use-broadcasted-txs.d.ts +8 -6
- package/build/hooks/use-chains.d.ts +3 -2
- package/build/hooks/use-route.d.ts +3 -2
- package/build/hooks/use-skip-client.d.ts +1 -1
- package/build/hooks/use-swap-widget.d.ts +1 -1
- package/build/hooks/use-usd-value.d.ts +3 -2
- package/build/index.es.js +166 -16
- package/build/index.es.js.map +1 -1
- package/build/lib/penumbra.d.ts +7 -0
- package/build/lib/wagmi.d.ts +2 -8986
- package/build/provider/index.d.ts +3 -2
- package/build/provider/skip-provider.d.ts +7 -10
- package/build/store/callbacks.d.ts +31 -0
- package/build/ui/index.d.ts +2 -1
- package/package.json +6 -2
package/build/index.es.js
CHANGED
|
@@ -14,7 +14,7 @@ import { arbitrum, avalanche, base, bsc, celo, fantom, filecoin, kava, linea, ma
|
|
|
14
14
|
import { QueryClient, QueryClientProvider, useQuery, useMutation } from '@tanstack/react-query';
|
|
15
15
|
import { WalletProvider as WalletProvider$1, useWallet } from '@solana/wallet-adapter-react';
|
|
16
16
|
import { PhantomWalletAdapter, SolflareWalletAdapter, CoinbaseWalletAdapter, TrustWalletAdapter, LedgerWalletAdapter } from '@solana/wallet-adapter-wallets';
|
|
17
|
-
import {
|
|
17
|
+
import { SkipClient } from '@skip-go/client';
|
|
18
18
|
import { getWalletClient } from '@wagmi/core';
|
|
19
19
|
import { createContext, useContext, useMemo, useCallback, useRef, useState, useEffect, forwardRef, Fragment as Fragment$1 } from 'react';
|
|
20
20
|
import { create } from 'zustand';
|
|
@@ -24,6 +24,10 @@ import { ArrowTopRightOnSquareIcon, ArrowLeftIcon as ArrowLeftIcon$1, ChevronDow
|
|
|
24
24
|
import { ArrowLeftIcon, FaceFrownIcon, ChevronDownIcon, BackspaceIcon, TrashIcon, CubeIcon, ArrowRightIcon, ArrowTopRightOnSquareIcon as ArrowTopRightOnSquareIcon$1, CheckCircleIcon, ArrowPathIcon, XCircleIcon, CheckIcon, ClipboardDocumentIcon, ChevronRightIcon, ExclamationTriangleIcon, InformationCircleIcon, PencilSquareIcon as PencilSquareIcon$1, FingerPrintIcon, ArrowsUpDownIcon } from '@heroicons/react/20/solid';
|
|
25
25
|
import * as ScrollArea from '@radix-ui/react-scroll-area';
|
|
26
26
|
import toast, { Toaster } from 'react-hot-toast';
|
|
27
|
+
import { createPenumbraClient } from '@penumbra-zone/client';
|
|
28
|
+
import { ViewService } from '@penumbra-zone/protobuf';
|
|
29
|
+
import { bech32mAddress } from '@penumbra-zone/bech32m/penumbra';
|
|
30
|
+
import { bech32CompatAddress } from '@penumbra-zone/bech32m/penumbracompat1';
|
|
27
31
|
import { clsx } from 'clsx';
|
|
28
32
|
import { twMerge } from 'tailwind-merge';
|
|
29
33
|
import { styled, useTheme, StyleSheetManager, ThemeProvider } from 'styled-components';
|
|
@@ -210,12 +214,12 @@ const SolanaProvider = ({ children }) => {
|
|
|
210
214
|
return (jsx(WalletProvider$1, { wallets: solanaWallets, localStorageKey: "ibc-fun-solana-wallet", autoConnect: true, children: children }, "skip-widget-solana-wallet"));
|
|
211
215
|
};
|
|
212
216
|
|
|
213
|
-
const defaultValues$
|
|
217
|
+
const defaultValues$5 = {
|
|
214
218
|
evm: undefined,
|
|
215
219
|
cosmos: undefined,
|
|
216
220
|
svm: undefined,
|
|
217
221
|
};
|
|
218
|
-
const useStore$1 = create(subscribeWithSelector(persist(() => defaultValues$
|
|
222
|
+
const useStore$1 = create(subscribeWithSelector(persist(() => defaultValues$5, {
|
|
219
223
|
name: 'TrackWalletState',
|
|
220
224
|
version: 2,
|
|
221
225
|
storage: createJSONStorage(() => window.sessionStorage),
|
|
@@ -308,10 +312,11 @@ function isReadyToCheckLedger(walletClient) {
|
|
|
308
312
|
}
|
|
309
313
|
|
|
310
314
|
const SkipContext = createContext(undefined);
|
|
311
|
-
function SkipProvider({ children, apiURL, endpointOptions, makeDestinationWallets, }) {
|
|
315
|
+
function SkipProvider({ children, apiURL, endpointOptions, makeDestinationWallets, chainIDsToAffiliates, }) {
|
|
312
316
|
const { getWalletRepo } = useManager();
|
|
313
317
|
const { wallets } = useWallet();
|
|
314
|
-
const skipClient = new
|
|
318
|
+
const skipClient = new SkipClient({
|
|
319
|
+
chainIDsToAffiliates,
|
|
315
320
|
getCosmosSigner: async (chainID) => {
|
|
316
321
|
var _a, _b;
|
|
317
322
|
const chainName = chainIdToName(chainID);
|
|
@@ -429,11 +434,11 @@ function isChainIdEvmos(chainID) {
|
|
|
429
434
|
return chainID === 'evmos_9001-2' || chainID.includes('evmos');
|
|
430
435
|
}
|
|
431
436
|
|
|
432
|
-
const defaultValues$
|
|
437
|
+
const defaultValues$4 = {
|
|
433
438
|
customGasAmount: DEFAULT_GAS_AMOUNT,
|
|
434
439
|
slippage: (3).toString(),
|
|
435
440
|
};
|
|
436
|
-
const useSettingsStore = create()(persist(() => defaultValues$
|
|
441
|
+
const useSettingsStore = create()(persist(() => defaultValues$4, {
|
|
437
442
|
name: 'SettingsState',
|
|
438
443
|
version: 4,
|
|
439
444
|
}));
|
|
@@ -720,8 +725,21 @@ const PenumbraWalletListItem = ({ children, walletName, ...props }) => {
|
|
|
720
725
|
return jsx("div", { ...props, children: children });
|
|
721
726
|
};
|
|
722
727
|
|
|
728
|
+
const defaultValues$3 = {};
|
|
729
|
+
const useCallbackStore = create()(() => defaultValues$3);
|
|
730
|
+
|
|
731
|
+
const penumbraBech32ChainIDs = ['noble-1', 'grand-1'];
|
|
732
|
+
const getPenumbraCompatibleAddress = ({ chainID, address, }) => {
|
|
733
|
+
if (!chainID)
|
|
734
|
+
return bech32mAddress(address);
|
|
735
|
+
return penumbraBech32ChainIDs.includes(chainID)
|
|
736
|
+
? bech32CompatAddress(address)
|
|
737
|
+
: bech32mAddress(address);
|
|
738
|
+
};
|
|
739
|
+
|
|
723
740
|
const useMakeWallets = () => {
|
|
724
741
|
const { data: chains } = useChains();
|
|
742
|
+
const { onWalletConnected, onWalletDisconnected } = useCallbackStore.getState();
|
|
725
743
|
const getChain = (_chainID) => chains === null || chains === void 0 ? void 0 : chains.find((chain) => chain.chainID === _chainID);
|
|
726
744
|
const { connector: currentConnector, address: evmAddress, isConnected: isEvmConnected, } = useAccount$1();
|
|
727
745
|
const { disconnectAsync } = useDisconnect();
|
|
@@ -742,6 +760,55 @@ const useMakeWallets = () => {
|
|
|
742
760
|
const chainType = (_a = getChain(chainID)) === null || _a === void 0 ? void 0 : _a.chainType;
|
|
743
761
|
let wallets = [];
|
|
744
762
|
if (chainType === 'cosmos') {
|
|
763
|
+
if (chainID.includes('penumbra')) {
|
|
764
|
+
const praxWallet = {
|
|
765
|
+
walletName: 'prax',
|
|
766
|
+
walletPrettyName: 'Prax Wallet',
|
|
767
|
+
walletInfo: {
|
|
768
|
+
logo: 'https://raw.githubusercontent.com/prax-wallet/web/e8b18f9b997708eab04f57e7a6c44f18b3cf13a8/apps/extension/public/prax-white-vertical.svg',
|
|
769
|
+
},
|
|
770
|
+
connect: async () => {
|
|
771
|
+
console.error('Prax wallet is not supported for connect');
|
|
772
|
+
toast.error('Prax wallet is not supported for connect');
|
|
773
|
+
},
|
|
774
|
+
getAddress: async ({ praxWallet }) => {
|
|
775
|
+
console.log('praxWallet', praxWallet);
|
|
776
|
+
const penumbraWalletIndex = praxWallet === null || praxWallet === void 0 ? void 0 : praxWallet.index;
|
|
777
|
+
const sourceChainID = praxWallet === null || praxWallet === void 0 ? void 0 : praxWallet.sourceChainID;
|
|
778
|
+
const prax_id = 'lkpmkhpnhknhmibgnmmhdhgdilepfghe';
|
|
779
|
+
const prax_origin = `chrome-extension://${prax_id}`;
|
|
780
|
+
const client = createPenumbraClient(prax_origin);
|
|
781
|
+
console.log(penumbraWalletIndex);
|
|
782
|
+
try {
|
|
783
|
+
await client.connect();
|
|
784
|
+
const viewService = client.service(ViewService);
|
|
785
|
+
const address = await viewService.addressByIndex({
|
|
786
|
+
addressIndex: {
|
|
787
|
+
account: penumbraWalletIndex ? penumbraWalletIndex : 0,
|
|
788
|
+
},
|
|
789
|
+
});
|
|
790
|
+
if (!address.address)
|
|
791
|
+
throw new Error('No address found');
|
|
792
|
+
const bech32Address = getPenumbraCompatibleAddress({
|
|
793
|
+
address: address.address,
|
|
794
|
+
chainID: sourceChainID,
|
|
795
|
+
});
|
|
796
|
+
return bech32Address;
|
|
797
|
+
}
|
|
798
|
+
catch (error) {
|
|
799
|
+
console.error(error);
|
|
800
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
801
|
+
// @ts-expect-error
|
|
802
|
+
toast.error(error === null || error === void 0 ? void 0 : error.message);
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
disconnect: async () => {
|
|
806
|
+
console.error('Prax wallet is not supported');
|
|
807
|
+
},
|
|
808
|
+
isWalletConnected: false,
|
|
809
|
+
};
|
|
810
|
+
return [praxWallet];
|
|
811
|
+
}
|
|
745
812
|
const chainName = chainIdToName(chainID);
|
|
746
813
|
const walletRepo = getWalletRepo(chainName);
|
|
747
814
|
wallets = walletRepo.wallets.map((wallet) => ({
|
|
@@ -754,6 +821,11 @@ const useMakeWallets = () => {
|
|
|
754
821
|
try {
|
|
755
822
|
await gracefullyConnect(wallet);
|
|
756
823
|
trackWallet.track('cosmos', wallet.walletName, chainType);
|
|
824
|
+
onWalletConnected === null || onWalletConnected === void 0 ? void 0 : onWalletConnected({
|
|
825
|
+
walletName: wallet.walletPrettyName,
|
|
826
|
+
chainId: chainID,
|
|
827
|
+
address: wallet.address,
|
|
828
|
+
});
|
|
757
829
|
}
|
|
758
830
|
catch (error) {
|
|
759
831
|
console.error(error);
|
|
@@ -794,6 +866,7 @@ const useMakeWallets = () => {
|
|
|
794
866
|
disconnect: async () => {
|
|
795
867
|
await wallet.disconnect();
|
|
796
868
|
trackWallet.untrack('cosmos');
|
|
869
|
+
onWalletDisconnected === null || onWalletDisconnected === void 0 ? void 0 : onWalletDisconnected({ chainType });
|
|
797
870
|
},
|
|
798
871
|
isWalletConnected: wallet.isWalletConnected,
|
|
799
872
|
}));
|
|
@@ -816,6 +889,11 @@ const useMakeWallets = () => {
|
|
|
816
889
|
try {
|
|
817
890
|
await connectAsync({ connector, chainId: Number(chainID) });
|
|
818
891
|
trackWallet.track('evm', connector.id, chainType);
|
|
892
|
+
onWalletConnected === null || onWalletConnected === void 0 ? void 0 : onWalletConnected({
|
|
893
|
+
walletName: connector.name,
|
|
894
|
+
chainId: chainID,
|
|
895
|
+
address: evmAddress,
|
|
896
|
+
});
|
|
819
897
|
}
|
|
820
898
|
catch (error) {
|
|
821
899
|
console.error(error);
|
|
@@ -853,6 +931,7 @@ const useMakeWallets = () => {
|
|
|
853
931
|
disconnect: async () => {
|
|
854
932
|
await disconnectAsync();
|
|
855
933
|
trackWallet.untrack('evm');
|
|
934
|
+
onWalletDisconnected === null || onWalletDisconnected === void 0 ? void 0 : onWalletDisconnected({ chainType });
|
|
856
935
|
},
|
|
857
936
|
isWalletConnected: connector.id === (currentConnector === null || currentConnector === void 0 ? void 0 : currentConnector.id),
|
|
858
937
|
};
|
|
@@ -868,9 +947,15 @@ const useMakeWallets = () => {
|
|
|
868
947
|
logo: wallet.adapter.icon,
|
|
869
948
|
},
|
|
870
949
|
connect: async () => {
|
|
950
|
+
var _a;
|
|
871
951
|
try {
|
|
872
952
|
await wallet.adapter.connect();
|
|
873
953
|
trackWallet.track('svm', wallet.adapter.name, chainType);
|
|
954
|
+
onWalletConnected === null || onWalletConnected === void 0 ? void 0 : onWalletConnected({
|
|
955
|
+
walletName: wallet.adapter.name,
|
|
956
|
+
chainId: chainID,
|
|
957
|
+
address: (_a = wallet.adapter.publicKey) === null || _a === void 0 ? void 0 : _a.toBase58(),
|
|
958
|
+
});
|
|
874
959
|
}
|
|
875
960
|
catch (error) {
|
|
876
961
|
console.error(error);
|
|
@@ -903,6 +988,7 @@ const useMakeWallets = () => {
|
|
|
903
988
|
disconnect: async () => {
|
|
904
989
|
await wallet.adapter.disconnect();
|
|
905
990
|
trackWallet.untrack('svm');
|
|
991
|
+
onWalletDisconnected === null || onWalletDisconnected === void 0 ? void 0 : onWalletDisconnected({ chainType });
|
|
906
992
|
},
|
|
907
993
|
isWalletConnected: wallet.adapter.connected,
|
|
908
994
|
isAvailable: wallet.readyState === 'Installed',
|
|
@@ -1095,8 +1181,8 @@ const apiURL = `${appUrl}/api/widget/skip`;
|
|
|
1095
1181
|
const WalletProvider = ({ children }) => {
|
|
1096
1182
|
return (jsx(SolanaProvider, { children: jsx(CosmosProvider, { children: jsx(EVMProvider, { children: jsx(WalletModalProvider, { children: children }) }) }) }));
|
|
1097
1183
|
};
|
|
1098
|
-
const SkipAPIProvider = ({ children, endpointOptions: endpointOptions$1 = endpointOptions, apiURL: apiURL$1 = apiURL, makeDestinationWallets, }) => {
|
|
1099
|
-
return (jsx(SkipProvider, { apiURL: apiURL$1, endpointOptions: endpointOptions$1, makeDestinationWallets: makeDestinationWallets, children: jsx(AssetsProvider, { children: children }) }));
|
|
1184
|
+
const SkipAPIProvider = ({ children, endpointOptions: endpointOptions$1 = endpointOptions, apiURL: apiURL$1 = apiURL, makeDestinationWallets, chainIDsToAffiliates, }) => {
|
|
1185
|
+
return (jsx(SkipProvider, { apiURL: apiURL$1, endpointOptions: endpointOptions$1, makeDestinationWallets: makeDestinationWallets, chainIDsToAffiliates: chainIDsToAffiliates, children: jsx(AssetsProvider, { children: children }) }));
|
|
1100
1186
|
};
|
|
1101
1187
|
const SwapWidgetProvider = ({ children, ...skipApiProviderProps }) => {
|
|
1102
1188
|
return (jsx(WalletProvider, { children: jsx(SkipAPIProvider, { ...skipApiProviderProps, children: children }) }));
|
|
@@ -3949,8 +4035,9 @@ const PraxWalletIndex = ({ praxWalletIndex, setPraxWalletIndex, }) => {
|
|
|
3949
4035
|
setPraxWalletIndex(Number(input));
|
|
3950
4036
|
setEditing(false);
|
|
3951
4037
|
};
|
|
3952
|
-
return isEditing ? (jsxs("div", { className: "flex items-center space-x-1 py-2 px-1", children: [jsx(StyledBorderDiv, { as: "input", type: "number", className: cn(`w-16 h-5.5 rounded-md border px-2 text-xs`), value: Number(input),
|
|
4038
|
+
return isEditing ? (jsxs("div", { className: "flex items-center space-x-1 py-2 px-1", children: [jsx(StyledBorderDiv, { as: "input", type: "number", className: cn(`w-16 h-5.5 rounded-md border px-2 text-xs`), value: Number(input), onClick: (e) => {
|
|
3953
4039
|
e.stopPropagation();
|
|
4040
|
+
}, onChange: (e) => {
|
|
3954
4041
|
if (Number(e.target.value) < 0) {
|
|
3955
4042
|
setInput(0);
|
|
3956
4043
|
return;
|
|
@@ -4043,6 +4130,7 @@ const SetAddressDialog = ({ open, onOpen, chain, index, signRequired, isDestinat
|
|
|
4043
4130
|
// currently only svm chainType that have isAvailable
|
|
4044
4131
|
return (jsxs(WalletListItem, { chainType: chainType, walletName: wallet.walletName, className: cn('group relative mb-2 data-[unsupported=true]:opacity-30', 'data-[unsupported=true]:before:absolute data-[unsupported=true]:before:inset-0 data-[unsupported=true]:before:cursor-not-allowed'), children: [jsxs(StyledThemedButton, { className: cn('flex w-full items-center gap-2 rounded-lg p-2 transition-colors focus:-outline-offset-2'), onClick: async () => {
|
|
4045
4132
|
var _a, _b;
|
|
4133
|
+
console.log('walletclicked', praxWalletIndex);
|
|
4046
4134
|
const resAddress = await ((_a = wallet.getAddress) === null || _a === void 0 ? void 0 : _a.call(wallet, {
|
|
4047
4135
|
signRequired,
|
|
4048
4136
|
context: isDestination ? 'destination' : 'recovery',
|
|
@@ -4138,7 +4226,8 @@ const useAutoSetAddress = ({ chain, chainID, index, enabled, signRequired, chain
|
|
|
4138
4226
|
if (index !== 0 &&
|
|
4139
4227
|
signRequired &&
|
|
4140
4228
|
(source === null || source === void 0 ? void 0 : source.chainType) === 'cosmos' &&
|
|
4141
|
-
cosmos
|
|
4229
|
+
cosmos &&
|
|
4230
|
+
!chain.chainID.includes('penumbra')) {
|
|
4142
4231
|
const walletSelected = wallets.find((wallet) => wallet.walletName === (cosmos === null || cosmos === void 0 ? void 0 : cosmos.walletName));
|
|
4143
4232
|
const address = await ((_a = walletSelected === null || walletSelected === void 0 ? void 0 : walletSelected.getAddress) === null || _a === void 0 ? void 0 : _a.call(walletSelected, { signRequired }));
|
|
4144
4233
|
if (walletSelected && address) {
|
|
@@ -4156,7 +4245,8 @@ const useAutoSetAddress = ({ chain, chainID, index, enabled, signRequired, chain
|
|
|
4156
4245
|
(destination === null || destination === void 0 ? void 0 : destination.chainType) === 'cosmos' &&
|
|
4157
4246
|
(destination === null || destination === void 0 ? void 0 : destination.source) !== 'input' &&
|
|
4158
4247
|
index !== 0 &&
|
|
4159
|
-
!signRequired
|
|
4248
|
+
!signRequired &&
|
|
4249
|
+
!chain.chainID.includes('penumbra')) {
|
|
4160
4250
|
const walletName = (_b = destination.source) === null || _b === void 0 ? void 0 : _b.walletName;
|
|
4161
4251
|
const walletSelected = wallets.find((wallet) => wallet.walletName === walletName);
|
|
4162
4252
|
const address = await ((_c = walletSelected === null || walletSelected === void 0 ? void 0 : walletSelected.getAddress) === null || _c === void 0 ? void 0 : _c.call(walletSelected, {}));
|
|
@@ -4712,6 +4802,7 @@ const PreviewRoute = ({ route, disclosure, isAmountError, }) => {
|
|
|
4712
4802
|
const { data: chains } = useChains();
|
|
4713
4803
|
const getChain = (chainID) => chains === null || chains === void 0 ? void 0 : chains.find((chain) => chain.chainID === chainID);
|
|
4714
4804
|
const { makeWallets } = useMakeWallets();
|
|
4805
|
+
const { onTransactionBroadcasted, onTransactionComplete, onTransactionFailed } = useCallbackStore.getState();
|
|
4715
4806
|
const [isExpanded, setIsExpanded] = useState(() => route.chainIDs.length === 2 ? true : false);
|
|
4716
4807
|
const [isOpen, control] = disclosure;
|
|
4717
4808
|
const [indexSetAddressDialogOpen, setIndexIsSetAddressDialogOpen] = useState();
|
|
@@ -4844,6 +4935,11 @@ const PreviewRoute = ({ route, disclosure, isAmountError, }) => {
|
|
|
4844
4935
|
explorerLink: txStatus.explorerLink,
|
|
4845
4936
|
},
|
|
4846
4937
|
];
|
|
4938
|
+
onTransactionBroadcasted === null || onTransactionBroadcasted === void 0 ? void 0 : onTransactionBroadcasted({
|
|
4939
|
+
chainId: txStatus.chainID,
|
|
4940
|
+
txHash: txStatus.txHash,
|
|
4941
|
+
explorerLink: txStatus.explorerLink,
|
|
4942
|
+
});
|
|
4847
4943
|
if (route.txsRequired === txs.length) {
|
|
4848
4944
|
toast.success(jsx("p", { children: "You can safely navigate away from this page while your transaction is pending" }), {
|
|
4849
4945
|
icon: (jsx(InformationCircleIcon, { className: "h-10 w-10 text-blue-500" })),
|
|
@@ -4859,6 +4955,11 @@ const PreviewRoute = ({ route, disclosure, isAmountError, }) => {
|
|
|
4859
4955
|
if (isUserRejectedRequestError(err)) {
|
|
4860
4956
|
throw new Error('User rejected request');
|
|
4861
4957
|
}
|
|
4958
|
+
onTransactionFailed === null || onTransactionFailed === void 0 ? void 0 : onTransactionFailed({
|
|
4959
|
+
error: err instanceof Error
|
|
4960
|
+
? `${err.name}: ${err.message}`
|
|
4961
|
+
: String(err)
|
|
4962
|
+
});
|
|
4862
4963
|
throw err;
|
|
4863
4964
|
}
|
|
4864
4965
|
}
|
|
@@ -4870,6 +4971,11 @@ const PreviewRoute = ({ route, disclosure, isAmountError, }) => {
|
|
|
4870
4971
|
},
|
|
4871
4972
|
onError: (err) => {
|
|
4872
4973
|
console.error(err);
|
|
4974
|
+
onTransactionFailed === null || onTransactionFailed === void 0 ? void 0 : onTransactionFailed({
|
|
4975
|
+
error: err instanceof Error
|
|
4976
|
+
? `${err.name}: ${err.message}`
|
|
4977
|
+
: String(err)
|
|
4978
|
+
});
|
|
4873
4979
|
toast(({ createdAt, id }) => (jsxs("div", { className: "flex flex-col", children: [jsx("h4", { className: "mb-2 font-bold", children: "Transaction Failed!" }), jsxs(StyledBorderDiv, { as: "pre", className: "mb-4 overflow-auto whitespace-pre-wrap break-all rounded border p-2 font-diatypeMono text-xs", children: [err instanceof Error
|
|
4874
4980
|
? `${err.name}: ${err.message}`
|
|
4875
4981
|
: String(err), jsx("br", {}), jsx("br", {}), new Date(createdAt).toISOString()] }), jsx("button", { className: "self-end text-sm font-medium text-red-500 hover:underline", onClick: () => toast.dismiss(id), children: "Clear Notification \u00D7" })] })), {
|
|
@@ -4881,6 +4987,16 @@ const PreviewRoute = ({ route, disclosure, isAmountError, }) => {
|
|
|
4881
4987
|
});
|
|
4882
4988
|
},
|
|
4883
4989
|
});
|
|
4990
|
+
useEffect(() => {
|
|
4991
|
+
var _a, _b, _c;
|
|
4992
|
+
if ((statusData === null || statusData === void 0 ? void 0 : statusData.isSuccess) && submitMutation.isSuccess) {
|
|
4993
|
+
onTransactionComplete === null || onTransactionComplete === void 0 ? void 0 : onTransactionComplete({
|
|
4994
|
+
txHash: (_a = broadcastedTxs === null || broadcastedTxs === void 0 ? void 0 : broadcastedTxs[0]) === null || _a === void 0 ? void 0 : _a.txHash,
|
|
4995
|
+
chainId: (_b = broadcastedTxs === null || broadcastedTxs === void 0 ? void 0 : broadcastedTxs[0]) === null || _b === void 0 ? void 0 : _b.chainID,
|
|
4996
|
+
explorerLink: (_c = broadcastedTxs === null || broadcastedTxs === void 0 ? void 0 : broadcastedTxs[0]) === null || _c === void 0 ? void 0 : _c.explorerLink,
|
|
4997
|
+
});
|
|
4998
|
+
}
|
|
4999
|
+
}, [statusData === null || statusData === void 0 ? void 0 : statusData.isSuccess, submitMutation.isSuccess]);
|
|
4884
5000
|
const SubmitButton = () => {
|
|
4885
5001
|
if (allAddressFilled) {
|
|
4886
5002
|
return (jsx(StyledBrandDiv, { as: "button", className: cn('w-full rounded-md py-4 font-semibold text-white', 'outline-none transition-transform', 'enabled:hover:rotate-1 enabled:hover:scale-102', 'disabled:cursor-not-allowed disabled:opacity-75'), onClick: () => submitMutation.mutate(), disabled: submitMutation.isPending ||
|
|
@@ -5203,7 +5319,7 @@ const WithStyledShadowDom = ({ children }) => {
|
|
|
5203
5319
|
return isClient ? (jsxs(Scope, { stylesheets: [css_248z, css_248z$2, css_248z$1], ref: onShadowDomLoaded, children: [jsx("div", { ref: onStyledComponentContainerLoaded }), jsx(StyleSheetManager, { target: styledComponentContainer, children: children })] })) : null;
|
|
5204
5320
|
};
|
|
5205
5321
|
|
|
5206
|
-
const SwapWidgetWithoutProviders = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, filter, ...swapWidgetUIProps }) => {
|
|
5322
|
+
const SwapWidgetWithoutProviders = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, filter, onWalletConnected, onWalletDisconnected, onTransactionBroadcasted, onTransactionComplete, onTransactionFailed, ...swapWidgetUIProps }) => {
|
|
5207
5323
|
useEffect(() => {
|
|
5208
5324
|
configureSwapWidget({
|
|
5209
5325
|
onlyTestnet,
|
|
@@ -5212,7 +5328,24 @@ const SwapWidgetWithoutProviders = ({ settings, onlyTestnet, defaultRoute, route
|
|
|
5212
5328
|
routeConfig,
|
|
5213
5329
|
filter,
|
|
5214
5330
|
});
|
|
5215
|
-
|
|
5331
|
+
useCallbackStore.setState({
|
|
5332
|
+
onWalletConnected,
|
|
5333
|
+
onWalletDisconnected,
|
|
5334
|
+
onTransactionBroadcasted,
|
|
5335
|
+
onTransactionComplete,
|
|
5336
|
+
onTransactionFailed,
|
|
5337
|
+
});
|
|
5338
|
+
}, [
|
|
5339
|
+
onlyTestnet,
|
|
5340
|
+
settings,
|
|
5341
|
+
defaultRoute,
|
|
5342
|
+
routeConfig,
|
|
5343
|
+
onWalletConnected,
|
|
5344
|
+
onWalletDisconnected,
|
|
5345
|
+
onTransactionBroadcasted,
|
|
5346
|
+
onTransactionComplete,
|
|
5347
|
+
onTransactionFailed,
|
|
5348
|
+
]);
|
|
5216
5349
|
const mergedThemes = useMemo(() => {
|
|
5217
5350
|
return {
|
|
5218
5351
|
...defaultTheme,
|
|
@@ -5221,7 +5354,7 @@ const SwapWidgetWithoutProviders = ({ settings, onlyTestnet, defaultRoute, route
|
|
|
5221
5354
|
}, [defaultTheme, theme]);
|
|
5222
5355
|
return (jsx(WithStyledShadowDom, { children: jsx(ThemeProvider, { theme: mergedThemes, children: jsx(SwapWidgetUI, { ...swapWidgetUIProps }) }) }));
|
|
5223
5356
|
};
|
|
5224
|
-
const SwapWidget = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, className, style, filter, toasterProps, persistSwapWidgetState, ...swapWidgetProviderProps }) => {
|
|
5357
|
+
const SwapWidget = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, className, style, filter, toasterProps, persistSwapWidgetState, onWalletConnected, onWalletDisconnected, onTransactionBroadcasted, onTransactionComplete, onTransactionFailed, ...swapWidgetProviderProps }) => {
|
|
5225
5358
|
useEffect(() => {
|
|
5226
5359
|
configureSwapWidget({
|
|
5227
5360
|
onlyTestnet,
|
|
@@ -5230,7 +5363,24 @@ const SwapWidget = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, c
|
|
|
5230
5363
|
routeConfig,
|
|
5231
5364
|
filter,
|
|
5232
5365
|
});
|
|
5233
|
-
|
|
5366
|
+
useCallbackStore.setState({
|
|
5367
|
+
onWalletConnected,
|
|
5368
|
+
onWalletDisconnected,
|
|
5369
|
+
onTransactionBroadcasted,
|
|
5370
|
+
onTransactionComplete,
|
|
5371
|
+
onTransactionFailed,
|
|
5372
|
+
});
|
|
5373
|
+
}, [
|
|
5374
|
+
onlyTestnet,
|
|
5375
|
+
settings,
|
|
5376
|
+
defaultRoute,
|
|
5377
|
+
routeConfig,
|
|
5378
|
+
onWalletConnected,
|
|
5379
|
+
onWalletDisconnected,
|
|
5380
|
+
onTransactionBroadcasted,
|
|
5381
|
+
onTransactionComplete,
|
|
5382
|
+
onTransactionFailed,
|
|
5383
|
+
]);
|
|
5234
5384
|
const mergedThemes = useMemo(() => {
|
|
5235
5385
|
return {
|
|
5236
5386
|
...defaultTheme,
|