@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/index.mjs
CHANGED
|
@@ -412,7 +412,7 @@ var init_constants = __esm({
|
|
|
412
412
|
"src/constants.ts"() {
|
|
413
413
|
"use strict";
|
|
414
414
|
SDK_NAME = "@trustware/sdk";
|
|
415
|
-
SDK_VERSION = "1.1.
|
|
415
|
+
SDK_VERSION = "1.1.7-staging.1";
|
|
416
416
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
417
417
|
GTM_ID = "GTM-TZDGNCXB";
|
|
418
418
|
API_PREFIX = "/api";
|
|
@@ -10868,7 +10868,7 @@ var init_WidgetSecurityFooter = __esm({
|
|
|
10868
10868
|
});
|
|
10869
10869
|
|
|
10870
10870
|
// src/widget/components/ImageLoader.tsx
|
|
10871
|
-
import { useEffect as useEffect19, useMemo as useMemo11, useRef as useRef9, useState as useState20 } from "react";
|
|
10871
|
+
import { useCallback as useCallback14, useEffect as useEffect19, useMemo as useMemo11, useRef as useRef9, useState as useState20 } from "react";
|
|
10872
10872
|
import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
10873
10873
|
function Skeleton({
|
|
10874
10874
|
background,
|
|
@@ -10893,7 +10893,6 @@ function ImageLoader({
|
|
|
10893
10893
|
retryDelay = 1e3,
|
|
10894
10894
|
lazy: lazy2 = true,
|
|
10895
10895
|
Fallback = null,
|
|
10896
|
-
// skeleton = null,
|
|
10897
10896
|
imgStyle,
|
|
10898
10897
|
onLoad,
|
|
10899
10898
|
onError
|
|
@@ -10903,6 +10902,12 @@ function ImageLoader({
|
|
|
10903
10902
|
const [srcIsEmpty, setSrcIsEmpty] = useState20(false);
|
|
10904
10903
|
const imgRef = useRef9(null);
|
|
10905
10904
|
const observerRef = useRef9(null);
|
|
10905
|
+
const onLoadRef = useRef9(onLoad);
|
|
10906
|
+
const onErrorRef = useRef9(onError);
|
|
10907
|
+
useEffect19(() => {
|
|
10908
|
+
onLoadRef.current = onLoad;
|
|
10909
|
+
onErrorRef.current = onError;
|
|
10910
|
+
}, [onLoad, onError]);
|
|
10906
10911
|
useEffect19(() => {
|
|
10907
10912
|
if (status === "error" && attempt < retry) {
|
|
10908
10913
|
const timer = setTimeout(() => {
|
|
@@ -10912,29 +10917,28 @@ function ImageLoader({
|
|
|
10912
10917
|
return () => clearTimeout(timer);
|
|
10913
10918
|
}
|
|
10914
10919
|
}, [status, attempt, retry, retryDelay]);
|
|
10915
|
-
const loadImage = () => {
|
|
10920
|
+
const loadImage = useCallback14(() => {
|
|
10916
10921
|
if (!src) {
|
|
10917
10922
|
setSrcIsEmpty(true);
|
|
10918
10923
|
return;
|
|
10919
10924
|
}
|
|
10925
|
+
setSrcIsEmpty(false);
|
|
10920
10926
|
setStatus("loading");
|
|
10921
10927
|
const img = new Image();
|
|
10922
10928
|
img.src = src;
|
|
10923
10929
|
img.onload = () => {
|
|
10924
10930
|
setStatus("success");
|
|
10925
|
-
|
|
10931
|
+
onLoadRef.current?.();
|
|
10926
10932
|
};
|
|
10927
10933
|
img.onerror = () => {
|
|
10928
10934
|
setStatus("error");
|
|
10929
|
-
|
|
10935
|
+
onErrorRef.current?.();
|
|
10930
10936
|
};
|
|
10931
|
-
};
|
|
10937
|
+
}, [src]);
|
|
10932
10938
|
useEffect19(() => {
|
|
10933
10939
|
if (!lazy2) {
|
|
10934
|
-
setTimeout(() =>
|
|
10935
|
-
|
|
10936
|
-
}, 0);
|
|
10937
|
-
return;
|
|
10940
|
+
const timer = setTimeout(() => loadImage(), 0);
|
|
10941
|
+
return () => clearTimeout(timer);
|
|
10938
10942
|
}
|
|
10939
10943
|
observerRef.current = new IntersectionObserver(
|
|
10940
10944
|
(entries) => {
|
|
@@ -10969,35 +10973,20 @@ function ImageLoader({
|
|
|
10969
10973
|
src,
|
|
10970
10974
|
alt,
|
|
10971
10975
|
style: {
|
|
10972
|
-
// Css guards to prevent external styles from interfering with image rendering
|
|
10973
10976
|
all: "revert",
|
|
10974
|
-
// Undo any inherited/global resets (e.g. Tailwind, normalize.css)
|
|
10975
10977
|
display: "block",
|
|
10976
|
-
// Prevent inline baseline gap
|
|
10977
10978
|
width: "100%",
|
|
10978
|
-
// Restore intended sizing
|
|
10979
10979
|
maxWidth: "100%",
|
|
10980
|
-
// Prevent overflow
|
|
10981
10980
|
height: "auto",
|
|
10982
|
-
// Maintain aspect ratio
|
|
10983
10981
|
border: "none",
|
|
10984
|
-
// Strip any border resets
|
|
10985
10982
|
padding: 0,
|
|
10986
|
-
// Strip padding resets
|
|
10987
10983
|
margin: 0,
|
|
10988
|
-
// Strip margin resets
|
|
10989
10984
|
objectFit: "cover",
|
|
10990
|
-
// Preserve visual intent
|
|
10991
10985
|
verticalAlign: "middle",
|
|
10992
|
-
// Guard against inline stripping
|
|
10993
10986
|
filter: "none",
|
|
10994
|
-
// Prevent inherited filter washes
|
|
10995
10987
|
opacity: 1,
|
|
10996
|
-
// Prevent inherited opacity stripping
|
|
10997
10988
|
mixBlendMode: "normal",
|
|
10998
|
-
// Prevent blend mode interference
|
|
10999
10989
|
colorScheme: "normal",
|
|
11000
|
-
// Prevent dark-mode inversion
|
|
11001
10990
|
...imgStyle
|
|
11002
10991
|
}
|
|
11003
10992
|
}
|
|
@@ -12572,7 +12561,7 @@ var init_TokenSelectorPanel = __esm({
|
|
|
12572
12561
|
});
|
|
12573
12562
|
|
|
12574
12563
|
// src/widget/features/token-selection/hooks/useOrderedWalletTokens.ts
|
|
12575
|
-
import { useCallback as
|
|
12564
|
+
import { useCallback as useCallback15, useMemo as useMemo12 } from "react";
|
|
12576
12565
|
function useOrderedWalletTokens({
|
|
12577
12566
|
amount,
|
|
12578
12567
|
amountInputMode,
|
|
@@ -12581,7 +12570,7 @@ function useOrderedWalletTokens({
|
|
|
12581
12570
|
setSelectedToken,
|
|
12582
12571
|
yourWalletTokens
|
|
12583
12572
|
}) {
|
|
12584
|
-
const handleTokenChange =
|
|
12573
|
+
const handleTokenChange = useCallback15(
|
|
12585
12574
|
async (token) => {
|
|
12586
12575
|
if (token) {
|
|
12587
12576
|
setSelectedToken(token);
|
|
@@ -12666,7 +12655,7 @@ var init_useOrderedWalletTokens = __esm({
|
|
|
12666
12655
|
});
|
|
12667
12656
|
|
|
12668
12657
|
// src/widget/features/token-selection/hooks/useSelectTokenModel.ts
|
|
12669
|
-
import { useCallback as
|
|
12658
|
+
import { useCallback as useCallback16, useMemo as useMemo13 } from "react";
|
|
12670
12659
|
function useSelectTokenModel({
|
|
12671
12660
|
goBack,
|
|
12672
12661
|
searchQuery,
|
|
@@ -12690,7 +12679,7 @@ function useSelectTokenModel({
|
|
|
12690
12679
|
explorerUrl: chain.blockExplorerUrls?.[0]
|
|
12691
12680
|
});
|
|
12692
12681
|
};
|
|
12693
|
-
const handleTokenSelect =
|
|
12682
|
+
const handleTokenSelect = useCallback16(
|
|
12694
12683
|
async (token) => {
|
|
12695
12684
|
if (token.balance !== void 0) {
|
|
12696
12685
|
setSelectedToken(token);
|
|
@@ -12714,7 +12703,7 @@ function useSelectTokenModel({
|
|
|
12714
12703
|
},
|
|
12715
12704
|
[goBack, selectedChain, setSelectedToken, walletAddress]
|
|
12716
12705
|
);
|
|
12717
|
-
const handleYourTokenSelect =
|
|
12706
|
+
const handleYourTokenSelect = useCallback16(
|
|
12718
12707
|
(token) => {
|
|
12719
12708
|
setSelectedToken(token);
|
|
12720
12709
|
setSelectedChain(token.chainData);
|
|
@@ -14429,7 +14418,7 @@ var init_HomePaymentOptions = __esm({
|
|
|
14429
14418
|
});
|
|
14430
14419
|
|
|
14431
14420
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
14432
|
-
import { useCallback as
|
|
14421
|
+
import { useCallback as useCallback17, useEffect as useEffect22, useMemo as useMemo16, useRef as useRef10, useState as useState21 } from "react";
|
|
14433
14422
|
function useHomeWalletActions({
|
|
14434
14423
|
connectWallet,
|
|
14435
14424
|
detectedWallets,
|
|
@@ -14458,7 +14447,7 @@ function useHomeWalletActions({
|
|
|
14458
14447
|
const { resetNavigation } = useDepositNavigationState("home");
|
|
14459
14448
|
const { setYourWalletTokens } = useDepositWallet();
|
|
14460
14449
|
const { isConnected, walletMetaId, connectedVia } = useWalletInfo();
|
|
14461
|
-
const handleWalletSelect =
|
|
14450
|
+
const handleWalletSelect = useCallback17(
|
|
14462
14451
|
async (wallet) => {
|
|
14463
14452
|
setIsCryptoDropdownOpen(false);
|
|
14464
14453
|
try {
|
|
@@ -14482,7 +14471,7 @@ function useHomeWalletActions({
|
|
|
14482
14471
|
const handleFiatSelect = () => {
|
|
14483
14472
|
setIsFiatDropdownOpen(false);
|
|
14484
14473
|
};
|
|
14485
|
-
const handleWalletConnect =
|
|
14474
|
+
const handleWalletConnect = useCallback17(async () => {
|
|
14486
14475
|
if (connectedVia !== "walletconnect" && isConnected) {
|
|
14487
14476
|
disconnect();
|
|
14488
14477
|
setYourWalletTokens([]);
|
|
@@ -14493,7 +14482,7 @@ function useHomeWalletActions({
|
|
|
14493
14482
|
const browserWallets = useMemo16(() => {
|
|
14494
14483
|
if (!detectedWallets?.length) return [];
|
|
14495
14484
|
return detectedWallets.filter(
|
|
14496
|
-
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem === selectedNamespace
|
|
14485
|
+
(wallet) => wallet?.meta?.id !== "walletconnect" && wallet?.meta?.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase()
|
|
14497
14486
|
);
|
|
14498
14487
|
}, [detectedWallets, selectedNamespace]);
|
|
14499
14488
|
return {
|
|
@@ -14881,7 +14870,6 @@ function useRoutePreviewModel({
|
|
|
14881
14870
|
walletAddress
|
|
14882
14871
|
}) {
|
|
14883
14872
|
const { chains } = useChains();
|
|
14884
|
-
console.log({ walletAddress });
|
|
14885
14873
|
const destinationConfig = useMemo17(
|
|
14886
14874
|
() => ({
|
|
14887
14875
|
dappName: config.messages?.title || "DApp",
|
|
@@ -15416,7 +15404,7 @@ var init_SuccessSummaryCard = __esm({
|
|
|
15416
15404
|
});
|
|
15417
15405
|
|
|
15418
15406
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
15419
|
-
import { useCallback as
|
|
15407
|
+
import { useCallback as useCallback18, useEffect as useEffect23, useMemo as useMemo18, useRef as useRef11, useState as useState22 } from "react";
|
|
15420
15408
|
import { encodeFunctionData, erc20Abi } from "viem";
|
|
15421
15409
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
15422
15410
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
@@ -15494,7 +15482,7 @@ function useTransactionActionModel({
|
|
|
15494
15482
|
const [isReadingAllowance, setIsReadingAllowance] = useState22(false);
|
|
15495
15483
|
const [isApproving, setIsApproving] = useState22(false);
|
|
15496
15484
|
const [gasReservationWei, setGasReservationWei] = useState22(0n);
|
|
15497
|
-
const readAllowance =
|
|
15485
|
+
const readAllowance = useCallback18(async () => {
|
|
15498
15486
|
if (!isEvm || isNativeSelected || !backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
15499
15487
|
setAllowanceWei(0n);
|
|
15500
15488
|
return;
|
|
@@ -15526,7 +15514,7 @@ function useTransactionActionModel({
|
|
|
15526
15514
|
void readAllowance();
|
|
15527
15515
|
}, [readAllowance]);
|
|
15528
15516
|
const needsApproval = isEvm && !isNativeSelected && !!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
15529
|
-
const waitForApprovalConfirmation =
|
|
15517
|
+
const waitForApprovalConfirmation = useCallback18(
|
|
15530
15518
|
async (chainId, txHash) => {
|
|
15531
15519
|
const timeoutMs = 12e4;
|
|
15532
15520
|
const intervalMs = 2e3;
|
|
@@ -15545,7 +15533,7 @@ function useTransactionActionModel({
|
|
|
15545
15533
|
},
|
|
15546
15534
|
[]
|
|
15547
15535
|
);
|
|
15548
|
-
const handleApproveExact =
|
|
15536
|
+
const handleApproveExact = useCallback18(async () => {
|
|
15549
15537
|
if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
|
|
15550
15538
|
return;
|
|
15551
15539
|
}
|
|
@@ -15638,7 +15626,7 @@ function useTransactionActionModel({
|
|
|
15638
15626
|
waitForApprovalConfirmation,
|
|
15639
15627
|
walletAddress
|
|
15640
15628
|
]);
|
|
15641
|
-
const getCachedFeeData =
|
|
15629
|
+
const getCachedFeeData = useCallback18(async () => {
|
|
15642
15630
|
if (!backendChainId2) return {};
|
|
15643
15631
|
const now = Date.now();
|
|
15644
15632
|
const cache = feeDataCacheRef.current;
|
|
@@ -15661,7 +15649,7 @@ function useTransactionActionModel({
|
|
|
15661
15649
|
}
|
|
15662
15650
|
return cache.inflight;
|
|
15663
15651
|
}, [backendChainId2]);
|
|
15664
|
-
const estimateGasReservationWei =
|
|
15652
|
+
const estimateGasReservationWei = useCallback18(async () => {
|
|
15665
15653
|
if (!isNativeSelected) {
|
|
15666
15654
|
setGasReservationWei(0n);
|
|
15667
15655
|
return 0n;
|
|
@@ -15730,7 +15718,7 @@ function useTransactionActionModel({
|
|
|
15730
15718
|
void estimateGasReservationWei();
|
|
15731
15719
|
}
|
|
15732
15720
|
}, [estimateGasReservationWei, routeResult]);
|
|
15733
|
-
const handleConfirm =
|
|
15721
|
+
const handleConfirm = useCallback18(async () => {
|
|
15734
15722
|
if (!routeResult) {
|
|
15735
15723
|
return;
|
|
15736
15724
|
}
|
|
@@ -15753,7 +15741,7 @@ function useTransactionActionModel({
|
|
|
15753
15741
|
submitTransaction,
|
|
15754
15742
|
trackEvent
|
|
15755
15743
|
]);
|
|
15756
|
-
const handleSwipeConfirm =
|
|
15744
|
+
const handleSwipeConfirm = useCallback18(async () => {
|
|
15757
15745
|
if (needsApproval) {
|
|
15758
15746
|
await handleApproveExact();
|
|
15759
15747
|
if (!backendChainId2 || !selectedTokenOnBackendChain || !selectedToken?.address || !walletAddress || !spender) {
|
|
@@ -16932,7 +16920,7 @@ import {
|
|
|
16932
16920
|
useState as useState23,
|
|
16933
16921
|
useEffect as useEffect27,
|
|
16934
16922
|
useRef as useRef13,
|
|
16935
|
-
useCallback as
|
|
16923
|
+
useCallback as useCallback19,
|
|
16936
16924
|
useImperativeHandle,
|
|
16937
16925
|
forwardRef
|
|
16938
16926
|
} from "react";
|
|
@@ -16991,7 +16979,7 @@ function WidgetInner({
|
|
|
16991
16979
|
const { resolvedTheme } = useDepositUi();
|
|
16992
16980
|
const { status, revalidate, errors } = useTrustware();
|
|
16993
16981
|
const [showConfirmDialog, setShowConfirmDialog] = useState23(false);
|
|
16994
|
-
const handleCloseRequest =
|
|
16982
|
+
const handleCloseRequest = useCallback19(() => {
|
|
16995
16983
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
16996
16984
|
setShowConfirmDialog(true);
|
|
16997
16985
|
} else {
|
|
@@ -17005,17 +16993,17 @@ function WidgetInner({
|
|
|
17005
16993
|
useEffect27(() => {
|
|
17006
16994
|
closeRequestRef.current = handleCloseRequest;
|
|
17007
16995
|
}, [handleCloseRequest, closeRequestRef]);
|
|
17008
|
-
const handleConfirmClose =
|
|
16996
|
+
const handleConfirmClose = useCallback19(() => {
|
|
17009
16997
|
setShowConfirmDialog(false);
|
|
17010
16998
|
onClose?.();
|
|
17011
16999
|
}, [onClose]);
|
|
17012
|
-
const handleCancelClose =
|
|
17000
|
+
const handleCancelClose = useCallback19(() => {
|
|
17013
17001
|
setShowConfirmDialog(false);
|
|
17014
17002
|
}, []);
|
|
17015
17003
|
const effectiveTheme = resolvedTheme;
|
|
17016
17004
|
const isRefreshing = status === "initializing";
|
|
17017
17005
|
const initBlocked = status === "error";
|
|
17018
|
-
const handleRefresh =
|
|
17006
|
+
const handleRefresh = useCallback19(() => {
|
|
17019
17007
|
revalidate?.();
|
|
17020
17008
|
}, [revalidate]);
|
|
17021
17009
|
return /* @__PURE__ */ jsxs43(Fragment7, { children: [
|
|
@@ -17087,11 +17075,11 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
17087
17075
|
const [isOpen, setIsOpen] = useState23(defaultOpen);
|
|
17088
17076
|
const closeRequestRef = useRef13(null);
|
|
17089
17077
|
const effectiveInitialStep = initialStep;
|
|
17090
|
-
const open =
|
|
17078
|
+
const open = useCallback19(() => {
|
|
17091
17079
|
setIsOpen(true);
|
|
17092
17080
|
onOpen?.();
|
|
17093
17081
|
}, [onOpen]);
|
|
17094
|
-
const close =
|
|
17082
|
+
const close = useCallback19(() => {
|
|
17095
17083
|
if (closeRequestRef.current) {
|
|
17096
17084
|
closeRequestRef.current();
|
|
17097
17085
|
} else {
|
|
@@ -17099,7 +17087,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
17099
17087
|
onClose?.();
|
|
17100
17088
|
}
|
|
17101
17089
|
}, [onClose]);
|
|
17102
|
-
const handleClose =
|
|
17090
|
+
const handleClose = useCallback19(() => {
|
|
17103
17091
|
setIsOpen(false);
|
|
17104
17092
|
onClose?.();
|
|
17105
17093
|
}, [onClose]);
|