@rash2x/bridge-widget 0.3.10 → 0.4.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.
@@ -1,27 +1,6 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
27
6
  const jsxRuntime = require("react/jsx-runtime");
@@ -47,7 +26,6 @@ const accordion = require("@/components/ui/accordion");
47
26
  const tooltip = require("@/components/ui/tooltip");
48
27
  const sonner = require("sonner");
49
28
  const reactDialog = require("@radix-ui/react-dialog");
50
- const ethers = require("ethers");
51
29
  const viem = require("viem");
52
30
  const tronwalletAdapters = require("@tronweb3/tronwallet-adapters");
53
31
  const card = require("@/components/ui/card");
@@ -432,16 +410,10 @@ function buildAssetMatrix(tokens) {
432
410
  if (!symbol) continue;
433
411
  (m[symbol] || (m[symbol] = {}))[t.chainKey] = t;
434
412
  }
435
- const chainStats = {};
436
413
  Object.values(m).forEach((byChain) => {
437
414
  Object.keys(byChain).forEach((chainKey) => {
438
- chainStats[chainKey] = (chainStats[chainKey] || 0) + 1;
439
415
  });
440
416
  });
441
- console.log(
442
- `[DEBUG] Asset matrix built: ${Object.keys(m).length} assets across chains:`,
443
- chainStats
444
- );
445
417
  return m;
446
418
  }
447
419
  function listAssetsForSelect(tokens) {
@@ -1550,12 +1522,6 @@ const useChainDerivations = () => {
1550
1522
  const byChain = assetMatrix[selectedAssetSymbol.toUpperCase()];
1551
1523
  const keys = new Set(Object.keys(byChain ?? {}));
1552
1524
  const result = chains.filter((c) => keys.has(c.chainKey));
1553
- console.log(
1554
- `[DEBUG] supportedFrom for ${selectedAssetSymbol}:`,
1555
- `${result.length} of ${chains.length} chains`,
1556
- result.map((c) => c.chainKey),
1557
- `| Has Arbitrum: ${result.some((c) => c.chainKey === "arbitrum")}`
1558
- );
1559
1525
  return result;
1560
1526
  }, [selectedAssetSymbol, assetMatrix, chains]);
1561
1527
  react.useEffect(() => {
@@ -1624,13 +1590,6 @@ const useChainDerivations = () => {
1624
1590
  if (fromChain?.chainKey) {
1625
1591
  list = list.filter((c) => c.chainKey !== fromChain.chainKey);
1626
1592
  }
1627
- console.log(
1628
- `[DEBUG] allowedToChains from ${fromChain?.chainKey}:`,
1629
- `${list.length} destinations`,
1630
- list.map((c) => c.chainKey),
1631
- `| Has Arbitrum: ${list.some((c) => c.chainKey === "arbitrum")}`,
1632
- `| API returned ${dest.length} tokens, filtered to ${filteredDest.length}`
1633
- );
1634
1593
  setAllowedToChains(list);
1635
1594
  if (!toChain || !list.some((c) => c.chainKey === toChain.chainKey)) {
1636
1595
  setToChain(list[0]);
@@ -1665,7 +1624,7 @@ const useChainDerivations = () => {
1665
1624
  isLoadingToChains
1666
1625
  };
1667
1626
  };
1668
- function useBalances(chainKey, address, priorityTokenSymbol) {
1627
+ function useBalances(chainKey, address) {
1669
1628
  const { chainRegistry } = useChainStrategies();
1670
1629
  const { assetMatrix } = useTokensStore();
1671
1630
  const tokensOnChain = react.useMemo(() => {
@@ -1679,27 +1638,13 @@ function useBalances(chainKey, address, priorityTokenSymbol) {
1679
1638
  }
1680
1639
  return tokensList;
1681
1640
  }, [assetMatrix, chainKey]);
1682
- const priorityToken = react.useMemo(() => {
1683
- if (!priorityTokenSymbol || !chainKey || !assetMatrix) return void 0;
1684
- const normalizedSymbol = normalizeTickerSymbol$1(priorityTokenSymbol);
1685
- const token = assetMatrix[normalizedSymbol]?.[chainKey];
1686
- if (token && token.address && token.address.length > 2) {
1687
- return token;
1688
- }
1689
- return void 0;
1690
- }, [priorityTokenSymbol, chainKey, assetMatrix]);
1691
1641
  const query = reactQuery.useQuery({
1692
- queryKey: ["balances", chainKey, address, priorityTokenSymbol],
1642
+ queryKey: ["balances", chainKey, address],
1693
1643
  queryFn: async () => {
1694
1644
  if (!address || !chainKey)
1695
1645
  return {};
1696
1646
  if (!isAddressValidForChain(chainKey, address)) return {};
1697
- return await chainRegistry.getBalances(
1698
- chainKey,
1699
- address,
1700
- tokensOnChain,
1701
- priorityToken
1702
- );
1647
+ return await chainRegistry.getBalances(chainKey, address, tokensOnChain);
1703
1648
  },
1704
1649
  enabled: !!address && !!chainKey && !!assetMatrix && tokensOnChain.length > 0 && isAddressValidForChain(chainKey, address),
1705
1650
  staleTime: 6e4,
@@ -1738,13 +1683,11 @@ function useSwapModel() {
1738
1683
  const { allowedFromChains, allowedToChains, isLoadingToChains } = useChainDerivations();
1739
1684
  const srcBalances = useBalances(
1740
1685
  chainsStore.fromChain?.chainKey,
1741
- srcAddress,
1742
- tokensStore.selectedAssetSymbol
1686
+ srcAddress
1743
1687
  );
1744
1688
  const dstBalances = useBalances(
1745
1689
  chainsStore.toChain?.chainKey,
1746
- dstAddress,
1747
- tokensStore.selectedAssetSymbol
1690
+ dstAddress
1748
1691
  );
1749
1692
  const { loading } = useBridgeQuote();
1750
1693
  const { inputAmount, setInputAmount, resetWithIdle } = useBridgeQuoteStore();
@@ -2671,15 +2614,15 @@ const EditIcon = (props) => {
2671
2614
  xmlns: "http://www.w3.org/2000/svg",
2672
2615
  ...props,
2673
2616
  children: [
2674
- /* @__PURE__ */ jsxRuntime.jsxs("g", { "clip-path": "url(#clip0_551_3851)", children: [
2617
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_551_3851)", children: [
2675
2618
  /* @__PURE__ */ jsxRuntime.jsx(
2676
2619
  "path",
2677
2620
  {
2678
2621
  d: "M9.76159 5.01068L4.91742 9.85489C4.72585 10.0465 4.54793 10.4023 4.50687 10.6622L4.24687 12.5096C4.15108 13.1801 4.61636 13.6454 5.28688 13.5496L7.13425 13.2896C7.39425 13.2486 7.76372 13.0707 7.94161 12.8791L12.7858 8.03491C13.6206 7.20018 14.0174 6.2286 12.7858 4.99702C11.5679 3.77913 10.5963 4.17594 9.76159 5.01068Z",
2679
2622
  stroke: "currentColor",
2680
- "stroke-miterlimit": "10",
2681
- "stroke-linecap": "round",
2682
- "stroke-linejoin": "round"
2623
+ strokeMiterlimit: "10",
2624
+ strokeLinecap: "round",
2625
+ strokeLinejoin: "round"
2683
2626
  }
2684
2627
  ),
2685
2628
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2687,9 +2630,9 @@ const EditIcon = (props) => {
2687
2630
  {
2688
2631
  d: "M9.0625 5.70312C9.47303 7.18102 10.6225 8.33049 12.1004 8.74101",
2689
2632
  stroke: "currentColor",
2690
- "stroke-miterlimit": "10",
2691
- "stroke-linecap": "round",
2692
- "stroke-linejoin": "round"
2633
+ strokeMiterlimit: "10",
2634
+ strokeLinecap: "round",
2635
+ strokeLinejoin: "round"
2693
2636
  }
2694
2637
  )
2695
2638
  ] }),
@@ -3774,7 +3717,7 @@ function useSilentValidations(amountString) {
3774
3717
  ]);
3775
3718
  return validationResult;
3776
3719
  }
3777
- const SubmitButton = () => {
3720
+ const MainButton = () => {
3778
3721
  const { t } = useBridgeTranslation();
3779
3722
  const { chainRegistry } = useChainStrategies();
3780
3723
  const { srcAddress, dstAddress } = useAddresses();
@@ -3852,11 +3795,11 @@ const SubmitButton = () => {
3852
3795
  ]);
3853
3796
  const handleClick = async () => {
3854
3797
  if (isBusy) return;
3855
- if (missingSrc && srcChainKey) {
3798
+ if (missingSrc) {
3856
3799
  onOpen("src");
3857
3800
  return;
3858
3801
  }
3859
- if (missingDst && dstChainKey) {
3802
+ if (missingDst) {
3860
3803
  onOpen("dst");
3861
3804
  return;
3862
3805
  }
@@ -3869,7 +3812,7 @@ const SubmitButton = () => {
3869
3812
  return;
3870
3813
  }
3871
3814
  };
3872
- const disabled = isBusy || amountNum <= 0 || status === "loading" || isBalanceLoading || hasInsufficientBalance || hasAmountTooLarge || !gas.hasEnoughGas || noRoute || !isValidForTransfer;
3815
+ const disabled = isBusy || status === "loading" || !missingSrc && !missingDst && (amountNum <= 0 || isBalanceLoading || hasInsufficientBalance || hasAmountTooLarge || !gas.hasEnoughGas || noRoute || !isValidForTransfer);
3873
3816
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-4", children: /* @__PURE__ */ jsxRuntime.jsx(
3874
3817
  button.Button,
3875
3818
  {
@@ -4096,9 +4039,9 @@ const ProgressStep = ({
4096
4039
  icon = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-16 h-16 animate-spin" })
4097
4040
  }) => {
4098
4041
  const { t } = useBridgeTranslation();
4099
- return /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogContent, { showCloseButton: false, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex relative flex-col gap-4 py-10 px-8 flex-1 items-center justify-start text-center noise bg-background", children: [
4042
+ return /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogContent, { showCloseButton: false, className: "overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex relative flex-col gap-4 flex-1 items-center justify-start text-center noise bg-background", children: [
4100
4043
  icon,
4101
- /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogTitle, { children: t("transaction.inProgress") }) }),
4044
+ /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogHeader, { className: "pr-0", children: /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogTitle, { children: t("transaction.inProgress") }) }),
4102
4045
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative mt-5 z-10", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute dot-vertical h-full left-5 top-0 bottom-0 z-0" }) })
4103
4046
  ] }) });
4104
4047
  };
@@ -4107,10 +4050,10 @@ const FailedStep = ({
4107
4050
  }) => {
4108
4051
  const { current, reset } = useTransactionStore();
4109
4052
  const { t } = useBridgeTranslation();
4110
- return /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogContent, { showCloseButton: false, children: [
4111
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col relative gap-4 py-10 px-8 flex-1 items-center justify-start text-center noise", children: [
4053
+ return /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogContent, { showCloseButton: true, className: "overflow-hidden", children: [
4054
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col relative gap-4 flex-1 items-center justify-start text-center noise", children: [
4112
4055
  icon,
4113
- /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogHeader, { children: [
4056
+ /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogHeader, { className: "pr-0", children: [
4114
4057
  /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogTitle, { children: t("transaction.failed") }),
4115
4058
  current?.errorCode && /* @__PURE__ */ jsxRuntime.jsx(reactDialog.DialogDescription, { children: t(
4116
4059
  `errors.${current.errorCode}`,
@@ -4222,10 +4165,10 @@ const SuccessStep = ({
4222
4165
  openTransactionInExplorer(srcChainKey, srcTxHash);
4223
4166
  }
4224
4167
  };
4225
- return /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogContent, { showCloseButton: false, children: [
4226
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 pt-10 px-8 flex-1 justify-start items-center text-center noise bg-background", children: [
4168
+ return /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogContent, { showCloseButton: true, className: "overflow-hidden", children: [
4169
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 flex-1 justify-start items-center text-center noise bg-background", children: [
4227
4170
  icon,
4228
- /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogTitle, { children: t("transaction.success") }) }),
4171
+ /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogHeader, { className: "pr-0", children: /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogTitle, { children: t("transaction.success") }) }),
4229
4172
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full space-y-2 mt-4 relative z-10 pb-14", children: [
4230
4173
  metadata?.srcAmountHuman && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center", children: [
4231
4174
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: t("transaction.bridged") }),
@@ -4273,7 +4216,7 @@ const SuccessStep = ({
4273
4216
  ] })
4274
4217
  ] })
4275
4218
  ] }),
4276
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-10 px-8", children: /* @__PURE__ */ jsxRuntime.jsx(button.Button, { onClick: reset, className: "w-full", children: t("transaction.done") }) })
4219
+ /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(button.Button, { onClick: reset, className: "w-full", children: t("transaction.done") }) })
4277
4220
  ] });
4278
4221
  };
4279
4222
  const useCountdown = (initialSeconds) => {
@@ -4298,9 +4241,9 @@ const ConfirmStep = ({
4298
4241
  }) => {
4299
4242
  const { t } = useBridgeTranslation();
4300
4243
  const { formatTime } = useCountdown(90);
4301
- return /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogContent, { showCloseButton: false, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col relative gap-4 py-10 px-8 flex-1 items-center justify-start text-center noise", children: [
4244
+ return /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogContent, { showCloseButton: false, className: "overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col relative gap-4 flex-1 items-center justify-start text-center noise", children: [
4302
4245
  icon,
4303
- /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogHeader, { children: [
4246
+ /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogHeader, { className: "pr-0", children: [
4304
4247
  /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogTitle, { children: t("transaction.confirm") }),
4305
4248
  /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogDescription, { children: t("transaction.signTransaction") })
4306
4249
  ] }),
@@ -4310,7 +4253,7 @@ const ConfirmStep = ({
4310
4253
  const StatusStepsDialog = ({
4311
4254
  icons
4312
4255
  }) => {
4313
- const { current } = useTransactionStore();
4256
+ const { current, reset } = useTransactionStore();
4314
4257
  const status = current?.status;
4315
4258
  if (!status || status === "idle") return null;
4316
4259
  let step = null;
@@ -4320,14 +4263,13 @@ const StatusStepsDialog = ({
4320
4263
  if (status === "processing") {
4321
4264
  step = /* @__PURE__ */ jsxRuntime.jsx(ProgressStep, { icon: icons?.progress });
4322
4265
  }
4323
- if (status === "failed") {
4266
+ if (status === "completed") {
4324
4267
  step = /* @__PURE__ */ jsxRuntime.jsx(FailedStep, { icon: icons?.failed });
4325
4268
  }
4326
- if (status === "completed") {
4269
+ if (status === "failed") {
4327
4270
  step = /* @__PURE__ */ jsxRuntime.jsx(SuccessStep, { icon: icons?.success });
4328
4271
  }
4329
- return /* @__PURE__ */ jsxRuntime.jsx(dialog.Dialog, { open: true, onOpenChange: () => {
4330
- }, children: step });
4272
+ return /* @__PURE__ */ jsxRuntime.jsx(dialog.Dialog, { open: true, onOpenChange: () => reset(), children: step });
4331
4273
  };
4332
4274
  const useTokens = () => {
4333
4275
  const { setTokens, setSelectedToken, setSelectedAssetSymbol } = useTokensStore();
@@ -4379,10 +4321,6 @@ const useChains = () => {
4379
4321
  });
4380
4322
  react.useEffect(() => {
4381
4323
  if (query.isSuccess && query.data?.length) {
4382
- console.log(
4383
- `[DEBUG] Loaded ${query.data.length} chains from API:`,
4384
- query.data.map((c) => c.chainKey)
4385
- );
4386
4324
  setChains(query.data);
4387
4325
  if (!fromChain) {
4388
4326
  setFromChain(query.data[0]);
@@ -4424,10 +4362,10 @@ class ChainStrategyRegistry {
4424
4362
  const strategy = this.getStrategy(chainKey);
4425
4363
  return strategy?.isConnected() || false;
4426
4364
  }
4427
- async getBalances(chainKey, address, tokens, priorityToken) {
4365
+ async getBalances(chainKey, address, tokens) {
4428
4366
  const strategy = this.getStrategy(chainKey);
4429
4367
  if (!strategy) return {};
4430
- return await strategy.getBalances(address, tokens, priorityToken);
4368
+ return await strategy.getBalances(address, tokens);
4431
4369
  }
4432
4370
  isAddressValid(chainKey, address) {
4433
4371
  const strategy = this.getStrategy(chainKey);
@@ -4495,7 +4433,7 @@ function parseTonAddress(address) {
4495
4433
  }
4496
4434
  return ton.Address.parse(address);
4497
4435
  }
4498
- async function getEvmBalances(publicClient, address, tokens, priorityToken) {
4436
+ async function getEvmBalances(publicClient, address, tokens) {
4499
4437
  const balances = {};
4500
4438
  try {
4501
4439
  if (!address || !viem.isAddress(address)) {
@@ -4507,56 +4445,8 @@ async function getEvmBalances(publicClient, address, tokens, priorityToken) {
4507
4445
  }
4508
4446
  const nativeTokens = tokens.filter((t) => isNativeAddress(t.address));
4509
4447
  const erc20Tokens = tokens.filter(
4510
- (t) => !isNativeAddress(t.address) && viem.isAddress(t.address) && (!priorityToken || t.address !== priorityToken.address)
4448
+ (t) => !isNativeAddress(t.address) && viem.isAddress(t.address)
4511
4449
  );
4512
- if (priorityToken) {
4513
- try {
4514
- const isPriorityNative = isNativeAddress(priorityToken.address);
4515
- if (isPriorityNative) {
4516
- const ethBalance = await publicClient.getBalance({
4517
- address
4518
- });
4519
- const balance = parseFloat(
4520
- viem.formatUnits(ethBalance, priorityToken.decimals)
4521
- );
4522
- if (balance > 0) {
4523
- balances[priorityToken.symbol] = { balance, address };
4524
- }
4525
- } else if (viem.isAddress(priorityToken.address)) {
4526
- const tokenBalance = await publicClient.readContract({
4527
- address: priorityToken.address,
4528
- abi: [
4529
- {
4530
- name: "balanceOf",
4531
- type: "function",
4532
- stateMutability: "view",
4533
- inputs: [{ name: "owner", type: "address" }],
4534
- outputs: [{ name: "balance", type: "uint256" }]
4535
- }
4536
- ],
4537
- functionName: "balanceOf",
4538
- args: [address]
4539
- });
4540
- const balance = parseFloat(
4541
- viem.formatUnits(tokenBalance, priorityToken.decimals)
4542
- );
4543
- if (balance > 0) {
4544
- balances[priorityToken.symbol] = { balance, address };
4545
- }
4546
- }
4547
- } catch (error) {
4548
- const errorMessage = error instanceof Error ? error.message : String(error);
4549
- const isZeroDataError = errorMessage.includes(
4550
- 'returned no data ("0x")'
4551
- );
4552
- if (!isZeroDataError) {
4553
- console.debug(
4554
- `Failed to get priority token balance for ${priorityToken.symbol}:`,
4555
- error
4556
- );
4557
- }
4558
- }
4559
- }
4560
4450
  for (const token of nativeTokens) {
4561
4451
  try {
4562
4452
  const ethBalance = await publicClient.getBalance({
@@ -4780,13 +4670,11 @@ const ERC20_ABI = [
4780
4670
  class EvmChainStrategy {
4781
4671
  constructor(config) {
4782
4672
  __publicField(this, "config");
4783
- __publicField(this, "provider");
4673
+ __publicField(this, "walletClient");
4784
4674
  __publicField(this, "publicClient");
4785
4675
  this.config = config;
4676
+ this.walletClient = config.walletClient;
4786
4677
  this.publicClient = config.publicClient;
4787
- if (config.walletClient) {
4788
- this.provider = new ethers.BrowserProvider(config.walletClient.transport);
4789
- }
4790
4678
  }
4791
4679
  canHandle(chainKey) {
4792
4680
  const key = chainKey.toLowerCase();
@@ -4822,9 +4710,9 @@ class EvmChainStrategy {
4822
4710
  return t("wallets.connectEvmWallet");
4823
4711
  }
4824
4712
  getClient() {
4825
- return this.provider;
4713
+ return this.walletClient;
4826
4714
  }
4827
- async getBalances(address, tokens, priorityToken) {
4715
+ async getBalances(address, tokens) {
4828
4716
  if (!this.publicClient) {
4829
4717
  console.warn("No publicClient available for balance query");
4830
4718
  return {};
@@ -4832,8 +4720,7 @@ class EvmChainStrategy {
4832
4720
  return await getEvmBalances(
4833
4721
  this.publicClient,
4834
4722
  address,
4835
- tokens,
4836
- priorityToken
4723
+ tokens
4837
4724
  );
4838
4725
  }
4839
4726
  isAddressValid(address) {
@@ -4859,7 +4746,7 @@ class EvmChainStrategy {
4859
4746
  }
4860
4747
  }
4861
4748
  async executeSteps(steps, _context, onFirstHash) {
4862
- if (!this.isConnected() || !this.provider) {
4749
+ if (!this.isConnected() || !this.walletClient) {
4863
4750
  throw new WalletNotConnectedError("evm");
4864
4751
  }
4865
4752
  this.validateSteps(steps);
@@ -4903,18 +4790,18 @@ class EvmChainStrategy {
4903
4790
  }
4904
4791
  async waitForCompletion(txHash) {
4905
4792
  try {
4906
- const provider = this.provider;
4907
- if (!provider) {
4793
+ const publicClient = this.publicClient;
4794
+ if (!publicClient) {
4908
4795
  throw new ProviderNotAvailableError("evm");
4909
4796
  }
4910
4797
  console.log(
4911
4798
  `Waiting for ${EVM_CONFIG.requiredConfirmations} confirmations for tx: ${txHash}`
4912
4799
  );
4913
- const receipt = await provider.waitForTransaction(
4914
- txHash,
4915
- EVM_CONFIG.requiredConfirmations,
4916
- EVM_CONFIG.timeout
4917
- );
4800
+ const receipt = await publicClient.waitForTransactionReceipt({
4801
+ hash: txHash,
4802
+ confirmations: EVM_CONFIG.requiredConfirmations,
4803
+ timeout: EVM_CONFIG.timeout
4804
+ });
4918
4805
  if (!receipt) {
4919
4806
  const error = new TransactionTimeoutError("evm", txHash);
4920
4807
  return {
@@ -4922,7 +4809,7 @@ class EvmChainStrategy {
4922
4809
  error: error.message
4923
4810
  };
4924
4811
  }
4925
- if (receipt.status !== 1) {
4812
+ if (receipt.status !== "success") {
4926
4813
  const error = new TransactionRevertedError("evm", txHash);
4927
4814
  return {
4928
4815
  completed: false,
@@ -4935,11 +4822,10 @@ class EvmChainStrategy {
4935
4822
  let actualFeeValue;
4936
4823
  try {
4937
4824
  const gasUsed = receipt.gasUsed;
4938
- const effectiveGasPrice = receipt.gasPrice;
4825
+ const effectiveGasPrice = receipt.effectiveGasPrice;
4939
4826
  if (gasUsed && effectiveGasPrice) {
4940
4827
  const feeWei = gasUsed * effectiveGasPrice;
4941
- const { formatUnits } = await import("ethers");
4942
- const feeInNative = formatUnits(feeWei, 18);
4828
+ const feeInNative = viem.formatUnits(feeWei, 18);
4943
4829
  actualFeeValue = feeInNative;
4944
4830
  console.log(`EVM transaction fee: ${feeInNative} (native token)`);
4945
4831
  }
@@ -4966,11 +4852,10 @@ class EvmChainStrategy {
4966
4852
  try {
4967
4853
  const receipt = error.receipt;
4968
4854
  const gasUsed = receipt.gasUsed;
4969
- const effectiveGasPrice = receipt.gasPrice || receipt.effectiveGasPrice;
4855
+ const effectiveGasPrice = receipt.effectiveGasPrice;
4970
4856
  if (gasUsed && effectiveGasPrice) {
4971
4857
  const feeWei = gasUsed * effectiveGasPrice;
4972
- const { formatUnits } = await import("ethers");
4973
- const feeInNative = formatUnits(feeWei, 18);
4858
+ const feeInNative = viem.formatUnits(feeWei, 18);
4974
4859
  actualFeeValue = feeInNative;
4975
4860
  console.log(
4976
4861
  `Replacement transaction fee: ${feeInNative} (native token)`
@@ -5004,8 +4889,10 @@ class EvmChainStrategy {
5004
4889
  }
5005
4890
  }
5006
4891
  async executeTransaction(step) {
5007
- const provider = this.provider;
5008
- const signer = await provider?.getSigner();
4892
+ const walletClient = this.walletClient;
4893
+ if (!walletClient) {
4894
+ throw new WalletNotConnectedError("evm");
4895
+ }
5009
4896
  if (!step.transaction) {
5010
4897
  throw new InvalidTransactionDataError(
5011
4898
  "evm",
@@ -5013,21 +4900,22 @@ class EvmChainStrategy {
5013
4900
  );
5014
4901
  }
5015
4902
  const tx = step.transaction;
5016
- const txRequest = {
4903
+ const hash = await walletClient.sendTransaction({
5017
4904
  to: tx.to,
5018
4905
  data: tx.data,
5019
- from: tx.from || this.config.evmAddress
5020
- };
5021
- if (tx.value) {
5022
- txRequest.value = tx.value;
5023
- }
5024
- const txResponse = await signer?.sendTransaction(txRequest);
5025
- return txResponse?.hash || "";
4906
+ account: tx.from || this.config.evmAddress,
4907
+ value: tx.value ? BigInt(tx.value) : void 0,
4908
+ chain: walletClient.chain
4909
+ });
4910
+ return hash;
5026
4911
  }
5027
4912
  async approveTransaction(step) {
5028
4913
  try {
5029
- const provider = this.provider;
5030
- const signer = await provider?.getSigner();
4914
+ const walletClient = this.walletClient;
4915
+ const publicClient = this.publicClient;
4916
+ if (!walletClient || !publicClient) {
4917
+ throw new WalletNotConnectedError("evm");
4918
+ }
5031
4919
  if (!step.transaction) {
5032
4920
  throw new InvalidTransactionDataError(
5033
4921
  "evm",
@@ -5050,16 +4938,26 @@ class EvmChainStrategy {
5050
4938
  );
5051
4939
  }
5052
4940
  const spenderAddress = "0x" + data.slice(34, 74);
5053
- const amount = "0x" + data.slice(74, 138);
5054
- const tokenContract = new ethers.Contract(tokenAddress, ERC20_ABI, signer);
5055
- const currentAllowance = await tokenContract.allowance(
5056
- this.config.evmAddress,
5057
- spenderAddress
5058
- );
4941
+ const amount = BigInt("0x" + data.slice(74, 138));
4942
+ const currentAllowance = await publicClient.readContract({
4943
+ address: tokenAddress,
4944
+ abi: ERC20_ABI,
4945
+ functionName: "allowance",
4946
+ args: [this.config.evmAddress, spenderAddress]
4947
+ });
5059
4948
  if (currentAllowance > 0n) {
5060
4949
  try {
5061
- const resetTx = await tokenContract.approve(spenderAddress, 0);
5062
- await resetTx.wait();
4950
+ const resetHash = await walletClient.writeContract({
4951
+ address: tokenAddress,
4952
+ abi: ERC20_ABI,
4953
+ functionName: "approve",
4954
+ args: [spenderAddress, 0n],
4955
+ account: this.config.evmAddress,
4956
+ chain: walletClient.chain
4957
+ });
4958
+ await publicClient.waitForTransactionReceipt({
4959
+ hash: resetHash
4960
+ });
5063
4961
  } catch (resetError) {
5064
4962
  throw new TransactionFailedError(
5065
4963
  "evm",
@@ -5072,8 +4970,15 @@ class EvmChainStrategy {
5072
4970
  console.log("USDT allowance is 0, no reset needed");
5073
4971
  }
5074
4972
  try {
5075
- const approveTx = await tokenContract.approve(spenderAddress, amount);
5076
- return approveTx.hash;
4973
+ const approveHash = await walletClient.writeContract({
4974
+ address: tokenAddress,
4975
+ abi: ERC20_ABI,
4976
+ functionName: "approve",
4977
+ args: [spenderAddress, amount],
4978
+ account: this.config.evmAddress,
4979
+ chain: walletClient.chain
4980
+ });
4981
+ return approveHash;
5077
4982
  } catch (approveError) {
5078
4983
  throw new TransactionFailedError(
5079
4984
  "evm",
@@ -5091,14 +4996,25 @@ class EvmChainStrategy {
5091
4996
  }
5092
4997
  async checkAllowance(tokenAddress, spenderAddress, amount) {
5093
4998
  try {
5094
- const provider = this.provider;
5095
- const tokenContract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
5096
- const allowance = await tokenContract.allowance(
5097
- this.config.evmAddress,
5098
- spenderAddress
5099
- );
5100
- const decimals = await tokenContract.decimals();
5101
- const requiredAmount = ethers.parseUnits(amount, decimals);
4999
+ const publicClient = this.publicClient;
5000
+ if (!publicClient) {
5001
+ return false;
5002
+ }
5003
+ const allowance = await publicClient.readContract({
5004
+ address: tokenAddress,
5005
+ abi: ERC20_ABI,
5006
+ functionName: "allowance",
5007
+ args: [
5008
+ this.config.evmAddress,
5009
+ spenderAddress
5010
+ ]
5011
+ });
5012
+ const decimals = await publicClient.readContract({
5013
+ address: tokenAddress,
5014
+ abi: ERC20_ABI,
5015
+ functionName: "decimals"
5016
+ });
5017
+ const requiredAmount = viem.parseUnits(amount, decimals);
5102
5018
  return allowance >= requiredAmount;
5103
5019
  } catch (error) {
5104
5020
  console.error("Error checking allowance:", error);
@@ -5118,11 +5034,13 @@ class EvmChainStrategy {
5118
5034
  */
5119
5035
  async checkFinality(blockNumber) {
5120
5036
  try {
5121
- const provider = this.provider;
5122
- if (!provider) {
5037
+ const publicClient = this.publicClient;
5038
+ if (!publicClient) {
5123
5039
  return false;
5124
5040
  }
5125
- const finalizedBlock = await provider.getBlock("finalized");
5041
+ const finalizedBlock = await publicClient.getBlock({
5042
+ blockTag: "finalized"
5043
+ });
5126
5044
  if (!finalizedBlock) {
5127
5045
  console.debug(
5128
5046
  "Finalized block not available (pre-merge or unsupported)"
@@ -6906,7 +6824,7 @@ const EvaaBridgeContent = ({
6906
6824
  }
6907
6825
  ),
6908
6826
  /* @__PURE__ */ jsxRuntime.jsx(AnotherAddress, {}),
6909
- /* @__PURE__ */ jsxRuntime.jsx(SubmitButton, {})
6827
+ /* @__PURE__ */ jsxRuntime.jsx(MainButton, {})
6910
6828
  ] }),
6911
6829
  /* @__PURE__ */ jsxRuntime.jsx(card.CardFooter, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(Details, {}) })
6912
6830
  ]