@skip-go/widget 3.12.2 → 3.12.4

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,9 +1,9 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import o, { useContext, useState, useMemo, useEffect, useRef, useDebugValue, createElement, useCallback, Fragment as Fragment$1, memo, forwardRef } from "react";
2
+ import o, { useContext, useState, useMemo, useEffect, useRef, useDebugValue, createElement, useCallback, Fragment as Fragment$1, memo, startTransition, forwardRef, Suspense } from "react";
3
3
  import { Scope } from "react-shadow-scope";
4
4
  import { atom as atom$1, useAtomValue, useAtom, useSetAtom, createStore, Provider } from "jotai";
5
5
  import NiceModal, { useModal } from "@ebay/nice-modal-react";
6
- import { assets, chains, bridges, venues, transactionStatus, ChainType, getSigningStargateClient, route, executeRoute, balances, FeeType, GAS_STATION_CHAIN_IDS, setClientOptions } from "@skip-go/client";
6
+ import { assets, chains, bridges, venues, transactionStatus, ChainType, getSigningStargateClient, route, executeRoute, balances, BridgeType, FeeType, GAS_STATION_CHAIN_IDS, setClientOptions } from "@skip-go/client";
7
7
  import { atomWithQuery, atomWithMutation } from "jotai-tanstack-query";
8
8
  import pluralize from "pluralize";
9
9
  import { track, setUserId, init as init$1, add } from "@amplitude/analytics-browser";
@@ -45294,7 +45294,7 @@ function walletConnect(parameters) {
45294
45294
  const optionalChains = config2.chains.map((x2) => x2.id);
45295
45295
  if (!optionalChains.length)
45296
45296
  return;
45297
- const { EthereumProvider } = await import("./index.es-D-hExlvU.js");
45297
+ const { EthereumProvider } = await import("./index.es-DJQaePo-.js");
45298
45298
  return await EthereumProvider.init({
45299
45299
  ...parameters,
45300
45300
  disableProviderPing: true,
@@ -48391,78 +48391,47 @@ const usdFormatter = new Intl.NumberFormat("en-US", {
48391
48391
  currency: "USD",
48392
48392
  maximumFractionDigits: 2
48393
48393
  });
48394
- const computeOpFee = (op) => {
48395
- if (op.type === OperationType.goFastTransfer && op.fee) {
48396
- const {
48397
- feeAsset: feeAsset2,
48398
- sourceChainFeeAmount,
48399
- destinationChainFeeAmount,
48400
- bpsFeeAmount,
48401
- sourceChainFeeUsd,
48402
- destinationChainFeeUsd,
48403
- bpsFeeUsd
48404
- } = op.fee;
48405
- const totalAmt = [sourceChainFeeAmount, destinationChainFeeAmount, bpsFeeAmount].reduce((s, a) => s + Number(a), 0).toString();
48406
- const totalUsd = [sourceChainFeeUsd, destinationChainFeeUsd, bpsFeeUsd].reduce(
48407
- (s, u) => s + Number(u),
48408
- 0
48409
- );
48410
- const human2 = convertTokenAmountToHumanReadableAmount(totalAmt, feeAsset2.decimals);
48411
- return {
48412
- assetAmount: Number(human2),
48413
- formattedAssetAmount: `${human2} ${feeAsset2.symbol}`,
48414
- formattedUsdAmount: formatUSD(totalUsd.toString())
48415
- };
48416
- }
48417
- const { feeAmount, feeAsset, usdFeeAmount } = op;
48418
- if (!feeAmount || !(feeAsset == null ? void 0 : feeAsset.decimals)) return;
48419
- const human = convertTokenAmountToHumanReadableAmount(feeAmount, feeAsset.decimals);
48420
- return {
48421
- assetAmount: Number(human),
48422
- formattedAssetAmount: `${human} ${feeAsset.symbol}`,
48423
- formattedUsdAmount: usdFeeAmount ? formatUSD(usdFeeAmount) : void 0
48424
- };
48425
- };
48426
- function computeSmartRelayFee(estimatedFees) {
48427
- const relay = estimatedFees.filter((f2) => f2.feeType === FeeType.SMART_RELAY);
48428
- if (!relay.length) return;
48429
- const totalAmt = relay.reduce((s, f2) => s + Number(f2.amount), 0).toString();
48430
- const totalUsd = relay.reduce((s, f2) => s + Number(f2.usdAmount), 0);
48431
- const { originAsset } = relay[0];
48432
- const decimals = originAsset.decimals ?? 6;
48433
- const human = convertTokenAmountToHumanReadableAmount(totalAmt, decimals);
48394
+ const getFeeDetail = (estimatedFee) => {
48395
+ const humanReadableAmount = convertTokenAmountToHumanReadableAmount(
48396
+ estimatedFee.amount ?? 0,
48397
+ estimatedFee.originAsset.decimals
48398
+ );
48399
+ const totalUsd = Number(estimatedFee.usdAmount);
48434
48400
  return {
48435
- assetAmount: Number(human),
48436
- formattedAssetAmount: `${human} ${originAsset.symbol}`,
48401
+ assetAmount: Number(humanReadableAmount),
48402
+ formattedAssetAmount: `${humanReadableAmount} ${estimatedFee.originAsset.symbol}`,
48437
48403
  formattedUsdAmount: formatUSD(totalUsd.toString())
48438
48404
  };
48439
- }
48405
+ };
48406
+ const BRIDGE_ID_TO_LABEL_MAP = {
48407
+ [BridgeType.IBC]: "IBC",
48408
+ [BridgeType.AXELAR]: "Axelar",
48409
+ [BridgeType.HYPERLANE]: "Hyperlane",
48410
+ [BridgeType.GO_FAST]: "Go-Fast",
48411
+ [BridgeType.OPINIT]: "OpInit",
48412
+ [BridgeType.CCTP]: "CCTP",
48413
+ [BridgeType.EUREKA]: "IBC Eureka",
48414
+ [BridgeType.STARGATE]: "Stargate",
48415
+ [BridgeType.LAYER_ZERO]: "Layer Zero"
48416
+ };
48440
48417
  function getFeeList(route2) {
48441
- const fees2 = [];
48442
- if (!route2.operations) return fees2;
48443
- const clientOps = getClientOperations(route2.operations);
48444
- clientOps.forEach((op) => {
48445
- const fee = computeOpFee(op);
48446
- if (!fee) return;
48447
- let label = "Bridge Fee";
48448
- switch (op.type) {
48449
- case OperationType.axelarTransfer:
48450
- label = "Axelar Bridging Fee";
48451
- break;
48452
- case OperationType.hyperlaneTransfer:
48453
- label = "Hyperlane Bridging Fee";
48454
- break;
48455
- case OperationType.goFastTransfer:
48456
- label = "Go-Fast Transfer Fee";
48457
- break;
48418
+ if (!route2.estimatedFees || route2.estimatedFees.length === 0) {
48419
+ return [];
48420
+ }
48421
+ return route2.estimatedFees.map((fee) => {
48422
+ if (fee.feeType === FeeType.SMART_RELAY) {
48423
+ return {
48424
+ label: "Smart Relay Fee",
48425
+ fee: getFeeDetail(fee)
48426
+ };
48458
48427
  }
48459
- fees2.push({ label, fee });
48428
+ const label = fee.bridgeId ? `${BRIDGE_ID_TO_LABEL_MAP[fee.bridgeId]} Bridging Fee` : "Bridging Fee";
48429
+ const feeDetail = getFeeDetail(fee);
48430
+ return {
48431
+ label,
48432
+ fee: feeDetail
48433
+ };
48460
48434
  });
48461
- const smartFee = computeSmartRelayFee(route2.estimatedFees || []);
48462
- if (smartFee) {
48463
- fees2.push({ label: "Smart Relay Fee", fee: smartFee });
48464
- }
48465
- return fees2;
48466
48435
  }
48467
48436
  function getTotalFees(fees2) {
48468
48437
  if (!fees2.length) return;
@@ -49332,7 +49301,7 @@ const SwapPageAssetChainInput = ({
49332
49301
  onMouseEnter: () => setIsAssetButtonHovered(true),
49333
49302
  onMouseLeave: () => setIsAssetButtonHovered(false),
49334
49303
  children: [
49335
- (assetDetails == null ? void 0 : assetDetails.assetImage) && assetDetails.symbol ? /* @__PURE__ */ jsxs(StyledAssetLabel, { align: "center", justify: "center", gap: 7, children: [
49304
+ assetDetails.symbol ? /* @__PURE__ */ jsxs(StyledAssetLabel, { align: "center", justify: "center", gap: 7, children: [
49336
49305
  /* @__PURE__ */ jsx(GroupedAssetImage, { height: 23, width: 23, groupedAsset }),
49337
49306
  /* @__PURE__ */ jsx(Text, { useWindowsTextHack: true, children: assetDetails.symbol }),
49338
49307
  isMobileScreenSize && /* @__PURE__ */ jsx(
@@ -52790,6 +52759,19 @@ const SwapPage = () => {
52790
52759
  routePreference,
52791
52760
  slippage
52792
52761
  });
52762
+ const navigateToSwapExecutionPage = () => {
52763
+ startTransition(() => {
52764
+ setError(void 0);
52765
+ setChainAddresses({});
52766
+ setSwapExecutionState();
52767
+ setUser({ username: sourceAccount == null ? void 0 : sourceAccount.address });
52768
+ if (sourceAccount == null ? void 0 : sourceAccount.address) {
52769
+ const replay = getReplay();
52770
+ replay == null ? void 0 : replay.start();
52771
+ }
52772
+ setCurrentPage(Routes.SwapExecutionPage);
52773
+ });
52774
+ };
52793
52775
  setUserId(sourceAccount == null ? void 0 : sourceAccount.address);
52794
52776
  if (showCosmosLedgerWarning) {
52795
52777
  track("warning page: cosmos ledger", { route: route2 });
@@ -52806,10 +52788,7 @@ const SwapPage = () => {
52806
52788
  setError({
52807
52789
  errorWarningType: ErrorWarningType.BadPriceWarning,
52808
52790
  onClickContinue: () => {
52809
- setError(void 0);
52810
- setChainAddresses({});
52811
- setCurrentPage(Routes.SwapExecutionPage);
52812
- setSwapExecutionState();
52791
+ navigateToSwapExecutionPage();
52813
52792
  },
52814
52793
  onClickBack: () => {
52815
52794
  setError(void 0);
@@ -52823,10 +52802,7 @@ const SwapPage = () => {
52823
52802
  setError({
52824
52803
  errorWarningType: ErrorWarningType.LowInfoWarning,
52825
52804
  onClickContinue: () => {
52826
- setError(void 0);
52827
- setChainAddresses({});
52828
- setCurrentPage(Routes.SwapExecutionPage);
52829
- setSwapExecutionState();
52805
+ navigateToSwapExecutionPage();
52830
52806
  },
52831
52807
  onClickBack: () => {
52832
52808
  setError(void 0);
@@ -52840,10 +52816,7 @@ const SwapPage = () => {
52840
52816
  setError({
52841
52817
  errorWarningType: ErrorWarningType.GoFastWarning,
52842
52818
  onClickContinue: () => {
52843
- setError(void 0);
52844
- setChainAddresses({});
52845
- setCurrentPage(Routes.SwapExecutionPage);
52846
- setSwapExecutionState();
52819
+ navigateToSwapExecutionPage();
52847
52820
  },
52848
52821
  onClickBack: () => {
52849
52822
  setCurrentPage(Routes.SwapPage);
@@ -52852,14 +52825,7 @@ const SwapPage = () => {
52852
52825
  });
52853
52826
  return;
52854
52827
  }
52855
- setChainAddresses({});
52856
- setCurrentPage(Routes.SwapExecutionPage);
52857
- setUser({ username: sourceAccount == null ? void 0 : sourceAccount.address });
52858
- if (sourceAccount == null ? void 0 : sourceAccount.address) {
52859
- const replay = getReplay();
52860
- replay == null ? void 0 : replay.start();
52861
- }
52862
- setSwapExecutionState();
52828
+ navigateToSwapExecutionPage();
52863
52829
  };
52864
52830
  return /* @__PURE__ */ jsx(
52865
52831
  MainButton,
@@ -54046,7 +54012,7 @@ const Router = () => {
54046
54012
  }
54047
54013
  switch (currentPage) {
54048
54014
  case Routes.SwapPage:
54049
- return /* @__PURE__ */ jsx(
54015
+ return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
54050
54016
  ErrorBoundary,
54051
54017
  {
54052
54018
  fallback: null,
@@ -54056,9 +54022,9 @@ const Router = () => {
54056
54022
  },
54057
54023
  children: /* @__PURE__ */ jsx(SwapPage, {})
54058
54024
  }
54059
- );
54025
+ ) });
54060
54026
  case Routes.SwapExecutionPage:
54061
- return /* @__PURE__ */ jsx(
54027
+ return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
54062
54028
  ErrorBoundary,
54063
54029
  {
54064
54030
  fallback: null,
@@ -54068,9 +54034,9 @@ const Router = () => {
54068
54034
  },
54069
54035
  children: /* @__PURE__ */ jsx(SwapExecutionPage, {})
54070
54036
  }
54071
- );
54037
+ ) });
54072
54038
  case Routes.TransactionHistoryPage:
54073
- return /* @__PURE__ */ jsx(
54039
+ return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
54074
54040
  ErrorBoundary,
54075
54041
  {
54076
54042
  fallback: null,
@@ -54082,7 +54048,7 @@ const Router = () => {
54082
54048
  },
54083
54049
  children: /* @__PURE__ */ jsx(TransactionHistoryPage, {})
54084
54050
  }
54085
- );
54051
+ ) });
54086
54052
  }
54087
54053
  };
54088
54054
  const useInitDefaultRoute = (defaultRoute) => {
@@ -54125,7 +54091,7 @@ const initSentry = () => {
54125
54091
  };
54126
54092
  const name = "@skip-go/widget";
54127
54093
  const description = "Swap widget";
54128
- const version = "3.12.2";
54094
+ const version = "3.12.4";
54129
54095
  const repository = {
54130
54096
  url: "https://github.com/skip-mev/skip-go",
54131
54097
  directory: "packages/widget"
@@ -54577,7 +54543,7 @@ const CosmosProvider = ({ children }) => {
54577
54543
  {
54578
54544
  grazOptions: {
54579
54545
  chains: isTestnet ? testnetChains : mainnetChains,
54580
- autoReconnect: false,
54546
+ autoReconnect: true,
54581
54547
  walletDefaultOptions: {
54582
54548
  sign: {
54583
54549
  preferNoSetFee: true,
@@ -1,4 +1,4 @@
1
- import { g as getAugmentedNamespace, c as commonjsGlobal, a as getDefaultExportFromCjs, p as process$1 } from "./index-B_YSz0du.js";
1
+ import { g as getAugmentedNamespace, c as commonjsGlobal, a as getDefaultExportFromCjs, p as process$1 } from "./index-BbqLTTYa.js";
2
2
  import qg, { PROPOSAL_EXPIRY_MESSAGE } from "@walletconnect/sign-client";
3
3
  const global = globalThis || void 0 || self;
4
4
  var buffer$1 = {};
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { W, d, l, o, r, s } from "./index-B_YSz0du.js";
1
+ import { W, d, l, o, r, s } from "./index-BbqLTTYa.js";
2
2
  export {
3
3
  W as Widget,
4
4
  d as defaultTheme,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@skip-go/widget",
3
3
  "description": "Swap widget",
4
- "version": "3.12.2",
4
+ "version": "3.12.4",
5
5
  "repository": {
6
6
  "url": "https://github.com/skip-mev/skip-go",
7
7
  "directory": "packages/widget"
@@ -42,7 +42,7 @@
42
42
  "@penumbra-zone/transport-dom": "^7.5.0",
43
43
  "@r2wc/react-to-web-component": "^2.0.3",
44
44
  "@sentry/react": "^8.46.0",
45
- "@skip-go/client": "1.3.1",
45
+ "@skip-go/client": "1.3.2",
46
46
  "@solana/spl-token": "^0.4.8",
47
47
  "@solana/wallet-adapter-ledger": "^0.9.25",
48
48
  "@solana/wallet-adapter-react": "^0.15.39",