@trustware/sdk-staging 1.1.6-staging.2 → 1.1.7-staging.1
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/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +1 -1
- package/dist/index.cjs +15 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +40 -52
- package/dist/index.mjs.map +1 -1
- package/dist/wallet.cjs +1 -1
- package/dist/wallet.mjs +1 -1
- package/dist/widget.cjs +15 -27
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +40 -52
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -567,7 +567,7 @@ var init_constants = __esm({
|
|
|
567
567
|
"src/constants.ts"() {
|
|
568
568
|
"use strict";
|
|
569
569
|
SDK_NAME = "@trustware/sdk";
|
|
570
|
-
SDK_VERSION = "1.1.
|
|
570
|
+
SDK_VERSION = "1.1.7-staging.1";
|
|
571
571
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
572
572
|
GTM_ID = "GTM-TZDGNCXB";
|
|
573
573
|
API_PREFIX = "/api";
|
|
@@ -10739,7 +10739,7 @@ var init_WidgetSecurityFooter = __esm({
|
|
|
10739
10739
|
});
|
|
10740
10740
|
|
|
10741
10741
|
// src/widget/components/ImageLoader.tsx
|
|
10742
|
-
import { useEffect as useEffect19, useMemo as useMemo11, useRef as useRef9, useState as useState20 } from "react";
|
|
10742
|
+
import { useCallback as useCallback14, useEffect as useEffect19, useMemo as useMemo11, useRef as useRef9, useState as useState20 } from "react";
|
|
10743
10743
|
import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
10744
10744
|
function Skeleton({
|
|
10745
10745
|
background,
|
|
@@ -10764,7 +10764,6 @@ function ImageLoader({
|
|
|
10764
10764
|
retryDelay = 1e3,
|
|
10765
10765
|
lazy: lazy2 = true,
|
|
10766
10766
|
Fallback = null,
|
|
10767
|
-
// skeleton = null,
|
|
10768
10767
|
imgStyle,
|
|
10769
10768
|
onLoad,
|
|
10770
10769
|
onError
|
|
@@ -10774,6 +10773,12 @@ function ImageLoader({
|
|
|
10774
10773
|
const [srcIsEmpty, setSrcIsEmpty] = useState20(false);
|
|
10775
10774
|
const imgRef = useRef9(null);
|
|
10776
10775
|
const observerRef = useRef9(null);
|
|
10776
|
+
const onLoadRef = useRef9(onLoad);
|
|
10777
|
+
const onErrorRef = useRef9(onError);
|
|
10778
|
+
useEffect19(() => {
|
|
10779
|
+
onLoadRef.current = onLoad;
|
|
10780
|
+
onErrorRef.current = onError;
|
|
10781
|
+
}, [onLoad, onError]);
|
|
10777
10782
|
useEffect19(() => {
|
|
10778
10783
|
if (status === "error" && attempt < retry) {
|
|
10779
10784
|
const timer = setTimeout(() => {
|
|
@@ -10783,29 +10788,28 @@ function ImageLoader({
|
|
|
10783
10788
|
return () => clearTimeout(timer);
|
|
10784
10789
|
}
|
|
10785
10790
|
}, [status, attempt, retry, retryDelay]);
|
|
10786
|
-
const loadImage = () => {
|
|
10791
|
+
const loadImage = useCallback14(() => {
|
|
10787
10792
|
if (!src) {
|
|
10788
10793
|
setSrcIsEmpty(true);
|
|
10789
10794
|
return;
|
|
10790
10795
|
}
|
|
10796
|
+
setSrcIsEmpty(false);
|
|
10791
10797
|
setStatus("loading");
|
|
10792
10798
|
const img = new Image();
|
|
10793
10799
|
img.src = src;
|
|
10794
10800
|
img.onload = () => {
|
|
10795
10801
|
setStatus("success");
|
|
10796
|
-
|
|
10802
|
+
onLoadRef.current?.();
|
|
10797
10803
|
};
|
|
10798
10804
|
img.onerror = () => {
|
|
10799
10805
|
setStatus("error");
|
|
10800
|
-
|
|
10806
|
+
onErrorRef.current?.();
|
|
10801
10807
|
};
|
|
10802
|
-
};
|
|
10808
|
+
}, [src]);
|
|
10803
10809
|
useEffect19(() => {
|
|
10804
10810
|
if (!lazy2) {
|
|
10805
|
-
setTimeout(() =>
|
|
10806
|
-
|
|
10807
|
-
}, 0);
|
|
10808
|
-
return;
|
|
10811
|
+
const timer = setTimeout(() => loadImage(), 0);
|
|
10812
|
+
return () => clearTimeout(timer);
|
|
10809
10813
|
}
|
|
10810
10814
|
observerRef.current = new IntersectionObserver(
|
|
10811
10815
|
(entries) => {
|
|
@@ -10840,35 +10844,20 @@ function ImageLoader({
|
|
|
10840
10844
|
src,
|
|
10841
10845
|
alt,
|
|
10842
10846
|
style: {
|
|
10843
|
-
// Css guards to prevent external styles from interfering with image rendering
|
|
10844
10847
|
all: "revert",
|
|
10845
|
-
// Undo any inherited/global resets (e.g. Tailwind, normalize.css)
|
|
10846
10848
|
display: "block",
|
|
10847
|
-
// Prevent inline baseline gap
|
|
10848
10849
|
width: "100%",
|
|
10849
|
-
// Restore intended sizing
|
|
10850
10850
|
maxWidth: "100%",
|
|
10851
|
-
// Prevent overflow
|
|
10852
10851
|
height: "auto",
|
|
10853
|
-
// Maintain aspect ratio
|
|
10854
10852
|
border: "none",
|
|
10855
|
-
// Strip any border resets
|
|
10856
10853
|
padding: 0,
|
|
10857
|
-
// Strip padding resets
|
|
10858
10854
|
margin: 0,
|
|
10859
|
-
// Strip margin resets
|
|
10860
10855
|
objectFit: "cover",
|
|
10861
|
-
// Preserve visual intent
|
|
10862
10856
|
verticalAlign: "middle",
|
|
10863
|
-
// Guard against inline stripping
|
|
10864
10857
|
filter: "none",
|
|
10865
|
-
// Prevent inherited filter washes
|
|
10866
10858
|
opacity: 1,
|
|
10867
|
-
// Prevent inherited opacity stripping
|
|
10868
10859
|
mixBlendMode: "normal",
|
|
10869
|
-
// Prevent blend mode interference
|
|
10870
10860
|
colorScheme: "normal",
|
|
10871
|
-
// Prevent dark-mode inversion
|
|
10872
10861
|
...imgStyle
|
|
10873
10862
|
}
|
|
10874
10863
|
}
|
|
@@ -12443,7 +12432,7 @@ var init_TokenSelectorPanel = __esm({
|
|
|
12443
12432
|
});
|
|
12444
12433
|
|
|
12445
12434
|
// src/widget/features/token-selection/hooks/useOrderedWalletTokens.ts
|
|
12446
|
-
import { useCallback as
|
|
12435
|
+
import { useCallback as useCallback15, useMemo as useMemo12 } from "react";
|
|
12447
12436
|
function useOrderedWalletTokens({
|
|
12448
12437
|
amount,
|
|
12449
12438
|
amountInputMode,
|
|
@@ -12452,7 +12441,7 @@ function useOrderedWalletTokens({
|
|
|
12452
12441
|
setSelectedToken,
|
|
12453
12442
|
yourWalletTokens
|
|
12454
12443
|
}) {
|
|
12455
|
-
const handleTokenChange =
|
|
12444
|
+
const handleTokenChange = useCallback15(
|
|
12456
12445
|
async (token) => {
|
|
12457
12446
|
if (token) {
|
|
12458
12447
|
setSelectedToken(token);
|
|
@@ -12537,7 +12526,7 @@ var init_useOrderedWalletTokens = __esm({
|
|
|
12537
12526
|
});
|
|
12538
12527
|
|
|
12539
12528
|
// src/widget/features/token-selection/hooks/useSelectTokenModel.ts
|
|
12540
|
-
import { useCallback as
|
|
12529
|
+
import { useCallback as useCallback16, useMemo as useMemo13 } from "react";
|
|
12541
12530
|
function useSelectTokenModel({
|
|
12542
12531
|
goBack,
|
|
12543
12532
|
searchQuery,
|
|
@@ -12561,7 +12550,7 @@ function useSelectTokenModel({
|
|
|
12561
12550
|
explorerUrl: chain.blockExplorerUrls?.[0]
|
|
12562
12551
|
});
|
|
12563
12552
|
};
|
|
12564
|
-
const handleTokenSelect =
|
|
12553
|
+
const handleTokenSelect = useCallback16(
|
|
12565
12554
|
async (token) => {
|
|
12566
12555
|
if (token.balance !== void 0) {
|
|
12567
12556
|
setSelectedToken(token);
|
|
@@ -12585,7 +12574,7 @@ function useSelectTokenModel({
|
|
|
12585
12574
|
},
|
|
12586
12575
|
[goBack, selectedChain, setSelectedToken, walletAddress]
|
|
12587
12576
|
);
|
|
12588
|
-
const handleYourTokenSelect =
|
|
12577
|
+
const handleYourTokenSelect = useCallback16(
|
|
12589
12578
|
(token) => {
|
|
12590
12579
|
setSelectedToken(token);
|
|
12591
12580
|
setSelectedChain(token.chainData);
|
|
@@ -14300,7 +14289,7 @@ var init_HomePaymentOptions = __esm({
|
|
|
14300
14289
|
});
|
|
14301
14290
|
|
|
14302
14291
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
14303
|
-
import { useCallback as
|
|
14292
|
+
import { useCallback as useCallback17, useEffect as useEffect22, useMemo as useMemo16, useRef as useRef10, useState as useState21 } from "react";
|
|
14304
14293
|
function useHomeWalletActions({
|
|
14305
14294
|
connectWallet,
|
|
14306
14295
|
detectedWallets,
|
|
@@ -14329,7 +14318,7 @@ function useHomeWalletActions({
|
|
|
14329
14318
|
const { resetNavigation } = useDepositNavigationState("home");
|
|
14330
14319
|
const { setYourWalletTokens } = useDepositWallet();
|
|
14331
14320
|
const { isConnected, walletMetaId, connectedVia } = useWalletInfo();
|
|
14332
|
-
const handleWalletSelect =
|
|
14321
|
+
const handleWalletSelect = useCallback17(
|
|
14333
14322
|
async (wallet) => {
|
|
14334
14323
|
setIsCryptoDropdownOpen(false);
|
|
14335
14324
|
try {
|
|
@@ -14353,7 +14342,7 @@ function useHomeWalletActions({
|
|
|
14353
14342
|
const handleFiatSelect = () => {
|
|
14354
14343
|
setIsFiatDropdownOpen(false);
|
|
14355
14344
|
};
|
|
14356
|
-
const handleWalletConnect =
|
|
14345
|
+
const handleWalletConnect = useCallback17(async () => {
|
|
14357
14346
|
if (connectedVia !== "walletconnect" && isConnected) {
|
|
14358
14347
|
disconnect();
|
|
14359
14348
|
setYourWalletTokens([]);
|
|
@@ -14364,7 +14353,7 @@ function useHomeWalletActions({
|
|
|
14364
14353
|
const browserWallets = useMemo16(() => {
|
|
14365
14354
|
if (!detectedWallets?.length) return [];
|
|
14366
14355
|
return detectedWallets.filter(
|
|
14367
|
-
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem === selectedNamespace
|
|
14356
|
+
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase()
|
|
14368
14357
|
);
|
|
14369
14358
|
}, [detectedWallets, selectedNamespace]);
|
|
14370
14359
|
return {
|
|
@@ -14752,7 +14741,6 @@ function useRoutePreviewModel({
|
|
|
14752
14741
|
walletAddress
|
|
14753
14742
|
}) {
|
|
14754
14743
|
const { chains } = useChains();
|
|
14755
|
-
console.log({ walletAddress });
|
|
14756
14744
|
const destinationConfig = useMemo17(
|
|
14757
14745
|
() => ({
|
|
14758
14746
|
dappName: config.messages?.title || "DApp",
|
|
@@ -15287,7 +15275,7 @@ var init_SuccessSummaryCard = __esm({
|
|
|
15287
15275
|
});
|
|
15288
15276
|
|
|
15289
15277
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
15290
|
-
import { useCallback as
|
|
15278
|
+
import { useCallback as useCallback18, useEffect as useEffect23, useMemo as useMemo18, useRef as useRef11, useState as useState22 } from "react";
|
|
15291
15279
|
import { encodeFunctionData, erc20Abi } from "viem";
|
|
15292
15280
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
15293
15281
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
@@ -15365,7 +15353,7 @@ function useTransactionActionModel({
|
|
|
15365
15353
|
const [isReadingAllowance, setIsReadingAllowance] = useState22(false);
|
|
15366
15354
|
const [isApproving, setIsApproving] = useState22(false);
|
|
15367
15355
|
const [gasReservationWei, setGasReservationWei] = useState22(0n);
|
|
15368
|
-
const readAllowance =
|
|
15356
|
+
const readAllowance = useCallback18(async () => {
|
|
15369
15357
|
if (!isEvm || isNativeSelected || !backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
15370
15358
|
setAllowanceWei(0n);
|
|
15371
15359
|
return;
|
|
@@ -15397,7 +15385,7 @@ function useTransactionActionModel({
|
|
|
15397
15385
|
void readAllowance();
|
|
15398
15386
|
}, [readAllowance]);
|
|
15399
15387
|
const needsApproval = isEvm && !isNativeSelected && !!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
15400
|
-
const waitForApprovalConfirmation =
|
|
15388
|
+
const waitForApprovalConfirmation = useCallback18(
|
|
15401
15389
|
async (chainId, txHash) => {
|
|
15402
15390
|
const timeoutMs = 12e4;
|
|
15403
15391
|
const intervalMs = 2e3;
|
|
@@ -15416,7 +15404,7 @@ function useTransactionActionModel({
|
|
|
15416
15404
|
},
|
|
15417
15405
|
[]
|
|
15418
15406
|
);
|
|
15419
|
-
const handleApproveExact =
|
|
15407
|
+
const handleApproveExact = useCallback18(async () => {
|
|
15420
15408
|
if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
|
|
15421
15409
|
return;
|
|
15422
15410
|
}
|
|
@@ -15509,7 +15497,7 @@ function useTransactionActionModel({
|
|
|
15509
15497
|
waitForApprovalConfirmation,
|
|
15510
15498
|
walletAddress
|
|
15511
15499
|
]);
|
|
15512
|
-
const getCachedFeeData =
|
|
15500
|
+
const getCachedFeeData = useCallback18(async () => {
|
|
15513
15501
|
if (!backendChainId2) return {};
|
|
15514
15502
|
const now = Date.now();
|
|
15515
15503
|
const cache = feeDataCacheRef.current;
|
|
@@ -15532,7 +15520,7 @@ function useTransactionActionModel({
|
|
|
15532
15520
|
}
|
|
15533
15521
|
return cache.inflight;
|
|
15534
15522
|
}, [backendChainId2]);
|
|
15535
|
-
const estimateGasReservationWei =
|
|
15523
|
+
const estimateGasReservationWei = useCallback18(async () => {
|
|
15536
15524
|
if (!isNativeSelected) {
|
|
15537
15525
|
setGasReservationWei(0n);
|
|
15538
15526
|
return 0n;
|
|
@@ -15601,7 +15589,7 @@ function useTransactionActionModel({
|
|
|
15601
15589
|
void estimateGasReservationWei();
|
|
15602
15590
|
}
|
|
15603
15591
|
}, [estimateGasReservationWei, routeResult]);
|
|
15604
|
-
const handleConfirm =
|
|
15592
|
+
const handleConfirm = useCallback18(async () => {
|
|
15605
15593
|
if (!routeResult) {
|
|
15606
15594
|
return;
|
|
15607
15595
|
}
|
|
@@ -15624,7 +15612,7 @@ function useTransactionActionModel({
|
|
|
15624
15612
|
submitTransaction,
|
|
15625
15613
|
trackEvent
|
|
15626
15614
|
]);
|
|
15627
|
-
const handleSwipeConfirm =
|
|
15615
|
+
const handleSwipeConfirm = useCallback18(async () => {
|
|
15628
15616
|
if (needsApproval) {
|
|
15629
15617
|
await handleApproveExact();
|
|
15630
15618
|
if (!backendChainId2 || !selectedTokenOnBackendChain || !selectedToken?.address || !walletAddress || !spender) {
|
|
@@ -16803,7 +16791,7 @@ import {
|
|
|
16803
16791
|
useState as useState23,
|
|
16804
16792
|
useEffect as useEffect27,
|
|
16805
16793
|
useRef as useRef13,
|
|
16806
|
-
useCallback as
|
|
16794
|
+
useCallback as useCallback19,
|
|
16807
16795
|
useImperativeHandle,
|
|
16808
16796
|
forwardRef
|
|
16809
16797
|
} from "react";
|
|
@@ -16862,7 +16850,7 @@ function WidgetInner({
|
|
|
16862
16850
|
const { resolvedTheme } = useDepositUi();
|
|
16863
16851
|
const { status, revalidate, errors } = useTrustware();
|
|
16864
16852
|
const [showConfirmDialog, setShowConfirmDialog] = useState23(false);
|
|
16865
|
-
const handleCloseRequest =
|
|
16853
|
+
const handleCloseRequest = useCallback19(() => {
|
|
16866
16854
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
16867
16855
|
setShowConfirmDialog(true);
|
|
16868
16856
|
} else {
|
|
@@ -16876,17 +16864,17 @@ function WidgetInner({
|
|
|
16876
16864
|
useEffect27(() => {
|
|
16877
16865
|
closeRequestRef.current = handleCloseRequest;
|
|
16878
16866
|
}, [handleCloseRequest, closeRequestRef]);
|
|
16879
|
-
const handleConfirmClose =
|
|
16867
|
+
const handleConfirmClose = useCallback19(() => {
|
|
16880
16868
|
setShowConfirmDialog(false);
|
|
16881
16869
|
onClose?.();
|
|
16882
16870
|
}, [onClose]);
|
|
16883
|
-
const handleCancelClose =
|
|
16871
|
+
const handleCancelClose = useCallback19(() => {
|
|
16884
16872
|
setShowConfirmDialog(false);
|
|
16885
16873
|
}, []);
|
|
16886
16874
|
const effectiveTheme = resolvedTheme;
|
|
16887
16875
|
const isRefreshing = status === "initializing";
|
|
16888
16876
|
const initBlocked = status === "error";
|
|
16889
|
-
const handleRefresh =
|
|
16877
|
+
const handleRefresh = useCallback19(() => {
|
|
16890
16878
|
revalidate?.();
|
|
16891
16879
|
}, [revalidate]);
|
|
16892
16880
|
return /* @__PURE__ */ jsxs43(Fragment7, { children: [
|
|
@@ -16958,11 +16946,11 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
16958
16946
|
const [isOpen, setIsOpen] = useState23(defaultOpen);
|
|
16959
16947
|
const closeRequestRef = useRef13(null);
|
|
16960
16948
|
const effectiveInitialStep = initialStep;
|
|
16961
|
-
const open =
|
|
16949
|
+
const open = useCallback19(() => {
|
|
16962
16950
|
setIsOpen(true);
|
|
16963
16951
|
onOpen?.();
|
|
16964
16952
|
}, [onOpen]);
|
|
16965
|
-
const close =
|
|
16953
|
+
const close = useCallback19(() => {
|
|
16966
16954
|
if (closeRequestRef.current) {
|
|
16967
16955
|
closeRequestRef.current();
|
|
16968
16956
|
} else {
|
|
@@ -16970,7 +16958,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
16970
16958
|
onClose?.();
|
|
16971
16959
|
}
|
|
16972
16960
|
}, [onClose]);
|
|
16973
|
-
const handleClose =
|
|
16961
|
+
const handleClose = useCallback19(() => {
|
|
16974
16962
|
setIsOpen(false);
|
|
16975
16963
|
onClose?.();
|
|
16976
16964
|
}, [onClose]);
|