@skip-go/widget 3.12.1 → 3.12.2

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.
@@ -5040,61 +5040,6 @@ function atomWithDebounce(delayMilliseconds = 250) {
5040
5040
  };
5041
5041
  }
5042
5042
  const callbacksAtom = atom$1();
5043
- const openDb = () => {
5044
- return new Promise((resolve, reject) => {
5045
- const request = indexedDB.open("skip-go-widget", 1);
5046
- request.onupgradeneeded = () => {
5047
- request.result.createObjectStore("atoms");
5048
- };
5049
- request.onsuccess = () => resolve(request.result);
5050
- request.onerror = () => reject(request.error);
5051
- });
5052
- };
5053
- const idbGet = async (key) => {
5054
- const db = await openDb();
5055
- return await new Promise((resolve, reject) => {
5056
- const tx = db.transaction("atoms", "readonly");
5057
- const store = tx.objectStore("atoms");
5058
- const request = store.get(key);
5059
- request.onsuccess = () => resolve(request.result);
5060
- request.onerror = () => reject(request.error);
5061
- });
5062
- };
5063
- const idbSet = async (key, value) => {
5064
- const db = await openDb();
5065
- return await new Promise((resolve, reject) => {
5066
- const tx = db.transaction("atoms", "readwrite");
5067
- const store = tx.objectStore("atoms");
5068
- const request = store.put(value, key);
5069
- request.onsuccess = () => resolve();
5070
- request.onerror = () => reject(request.error);
5071
- });
5072
- };
5073
- const idbDelete = async (key) => {
5074
- const db = await openDb();
5075
- return await new Promise((resolve, reject) => {
5076
- const tx = db.transaction("atoms", "readwrite");
5077
- const store = tx.objectStore("atoms");
5078
- const request = store.delete(key);
5079
- request.onsuccess = () => resolve();
5080
- request.onerror = () => reject(request.error);
5081
- });
5082
- };
5083
- function atomWithIndexedDBStorage(storageKey, initialValue) {
5084
- const defaultStorage2 = {
5085
- getItem: async (key) => {
5086
- const value = await idbGet(key);
5087
- return value ?? initialValue;
5088
- },
5089
- setItem: async (key, newValue) => {
5090
- await idbSet(key, newValue);
5091
- },
5092
- removeItem: async (key) => {
5093
- await idbDelete(key);
5094
- }
5095
- };
5096
- return atomWithStorage(storageKey, initialValue, defaultStorage2, { getOnInit: true });
5097
- }
5098
5043
  function atomWithStorageNoCrossTabSync(storageKey, initialValue) {
5099
5044
  const defaultStorage2 = {
5100
5045
  getItem: (key) => {
@@ -5182,6 +5127,7 @@ var LOCAL_STORAGE_KEYS = /* @__PURE__ */ ((LOCAL_STORAGE_KEYS2) => {
5182
5127
  LOCAL_STORAGE_KEYS2["sourceAsset"] = "sourceAsset";
5183
5128
  LOCAL_STORAGE_KEYS2["destinationAsset"] = "destinationAsset";
5184
5129
  LOCAL_STORAGE_KEYS2["transactionHistory"] = "transactionHistory";
5130
+ LOCAL_STORAGE_KEYS2["transactionHistoryVersion"] = "transactionHistoryVersion";
5185
5131
  LOCAL_STORAGE_KEYS2["swapExecutionState"] = "swapExecutionState";
5186
5132
  LOCAL_STORAGE_KEYS2["extraCosmosChainIdsToConnectPerWallet"] = "extraCosmosChainIdsToConnectPerWallet";
5187
5133
  return LOCAL_STORAGE_KEYS2;
@@ -41379,14 +41325,22 @@ const setRouteToDefaultRouteAtom = atom$1(null, (get, set, assets2) => {
41379
41325
  set(destinationAssetAmountAtom, amountOut == null ? void 0 : amountOut.toString());
41380
41326
  }
41381
41327
  });
41382
- const transactionHistoryAtom = atomWithIndexedDBStorage(
41328
+ var HISTORY_VERSION = /* @__PURE__ */ ((HISTORY_VERSION2) => {
41329
+ HISTORY_VERSION2[HISTORY_VERSION2["camelCase"] = 0] = "camelCase";
41330
+ return HISTORY_VERSION2;
41331
+ })(HISTORY_VERSION || {});
41332
+ const transactionHistoryVersionAtom = atomWithStorage(
41333
+ LOCAL_STORAGE_KEYS.transactionHistoryVersion,
41334
+ void 0
41335
+ );
41336
+ const transactionHistoryAtom = atomWithStorage(
41383
41337
  LOCAL_STORAGE_KEYS.transactionHistory,
41384
41338
  []
41385
41339
  );
41386
41340
  const setTransactionHistoryAtom = atom$1(
41387
41341
  null,
41388
- async (get, set, historyItem) => {
41389
- const history = await get(transactionHistoryAtom);
41342
+ (get, set, historyItem) => {
41343
+ const history = get(transactionHistoryAtom);
41390
41344
  const index = history.findIndex((item) => item.timestamp === historyItem.timestamp);
41391
41345
  const newHistory = [...history];
41392
41346
  if (index !== -1) {
@@ -41398,8 +41352,8 @@ const setTransactionHistoryAtom = atom$1(
41398
41352
  set(transactionHistoryAtom, newHistory);
41399
41353
  }
41400
41354
  );
41401
- const lastTransactionInTimeAtom = atom$1(async (get) => {
41402
- const history = await get(transactionHistoryAtom);
41355
+ const lastTransactionInTimeAtom = atom$1((get) => {
41356
+ const history = get(transactionHistoryAtom);
41403
41357
  if (history.length === 0) return;
41404
41358
  const sorted = [...history].sort((a, b) => b.timestamp - a.timestamp);
41405
41359
  const lastTx = sorted[0];
@@ -41409,8 +41363,8 @@ const lastTransactionInTimeAtom = atom$1(async (get) => {
41409
41363
  index: originalIndex
41410
41364
  };
41411
41365
  });
41412
- const removeTransactionHistoryItemAtom = atom$1(null, async (get, set, timestamp) => {
41413
- const history = await get(transactionHistoryAtom);
41366
+ const removeTransactionHistoryItemAtom = atom$1(null, (get, set, timestamp) => {
41367
+ const history = get(transactionHistoryAtom);
41414
41368
  if (!history || isNaN(timestamp)) return;
41415
41369
  const newHistory = history.filter((item) => item.timestamp !== timestamp);
41416
41370
  set(transactionHistoryAtom, newHistory);
@@ -45340,7 +45294,7 @@ function walletConnect(parameters) {
45340
45294
  const optionalChains = config2.chains.map((x2) => x2.id);
45341
45295
  if (!optionalChains.length)
45342
45296
  return;
45343
- const { EthereumProvider } = await import("./index.es-Cu1s5TVX.js");
45297
+ const { EthereumProvider } = await import("./index.es-D-hExlvU.js");
45344
45298
  return await EthereumProvider.init({
45345
45299
  ...parameters,
45346
45300
  disableProviderPing: true,
@@ -45736,6 +45690,11 @@ const setSwapExecutionStateAtom = atom$1(null, (get, set) => {
45736
45690
  timestamp: Date.now()
45737
45691
  });
45738
45692
  set(submitSwapExecutionCallbacksAtom, {
45693
+ onTransactionSignRequested: async (props) => {
45694
+ var _a2;
45695
+ track("execute route: transaction sign requested", { props });
45696
+ (_a2 = callbacks == null ? void 0 : callbacks.onTransactionSignRequested) == null ? void 0 : _a2.call(callbacks, props);
45697
+ },
45739
45698
  onTransactionUpdated: (txInfo) => {
45740
45699
  var _a2;
45741
45700
  track("execute route: transaction updated", { txInfo });
@@ -52568,14 +52527,14 @@ const TrackLatestTxHistoryItemStatus = memo(() => {
52568
52527
  }
52569
52528
  return null;
52570
52529
  });
52571
- const noHistoryItemsAtom = atom$1(async (get) => {
52572
- const txHistoryItems = await get(transactionHistoryAtom);
52530
+ const noHistoryItemsAtom = atom$1((get) => {
52531
+ const txHistoryItems = get(transactionHistoryAtom);
52573
52532
  return (txHistoryItems == null ? void 0 : txHistoryItems.length) === 0;
52574
52533
  });
52575
- const isFetchingLastTransactionStatusAtom = atom$1(async (get) => {
52534
+ const isFetchingLastTransactionStatusAtom = atom$1((get) => {
52576
52535
  var _a, _b, _c;
52577
52536
  const { overallStatus, route: route2, transactionsSigned } = get(swapExecutionStateAtom);
52578
- const lastTxHistoryItemInTime = await get(lastTransactionInTimeAtom);
52537
+ const lastTxHistoryItemInTime = get(lastTransactionInTimeAtom);
52579
52538
  return overallStatus === "pending" && transactionsSigned === (route2 == null ? void 0 : route2.txsRequired) || ((_a = lastTxHistoryItemInTime == null ? void 0 : lastTxHistoryItemInTime.transactionHistoryItem) == null ? void 0 : _a.isSettled) !== true && ((_c = (_b = lastTxHistoryItemInTime == null ? void 0 : lastTxHistoryItemInTime.transactionHistoryItem) == null ? void 0 : _b.route) == null ? void 0 : _c.txsRequired) === 1;
52580
52539
  });
52581
52540
  const useConnectToMissingCosmosChain = () => {
@@ -54166,7 +54125,7 @@ const initSentry = () => {
54166
54125
  };
54167
54126
  const name = "@skip-go/widget";
54168
54127
  const description = "Swap widget";
54169
- const version = "3.12.1";
54128
+ const version = "3.12.2";
54170
54129
  const repository = {
54171
54130
  url: "https://github.com/skip-mev/skip-go",
54172
54131
  directory: "packages/widget"
@@ -54475,7 +54434,8 @@ const useInitWidget = (props) => {
54475
54434
  onRouteUpdated: props.onRouteUpdated,
54476
54435
  onSourceAndDestinationSwapped: props.onSourceAndDestinationSwapped,
54477
54436
  onSourceAssetUpdated: props.onSourceAssetUpdated,
54478
- onDestinationAssetUpdated: props.onDestinationAssetUpdated
54437
+ onDestinationAssetUpdated: props.onDestinationAssetUpdated,
54438
+ onTransactionSignRequested: props.onTransactionSignRequested
54479
54439
  };
54480
54440
  if (Object.values(callbacks).some((callback) => callback !== void 0)) {
54481
54441
  setCallbacks(callbacks);
@@ -54517,7 +54477,8 @@ const useInitWidget = (props) => {
54517
54477
  props.onSourceAssetUpdated,
54518
54478
  props.onDestinationAssetUpdated,
54519
54479
  props.batchSignTxs,
54520
- setBatchSignTxs
54480
+ setBatchSignTxs,
54481
+ props.onTransactionSignRequested
54521
54482
  ]);
54522
54483
  return { theme: mergedTheme };
54523
54484
  };
@@ -54536,19 +54497,45 @@ const useInitGetSigners = (props) => {
54536
54497
  }));
54537
54498
  }, [props.getCosmosSigner, props.getEvmSigner, props.getSvmSigner, setGetSigners]);
54538
54499
  };
54539
- const migrateHistoryFromLocalStorageToIndexedDB = async () => {
54500
+ const migrateOldLocalStorageValues = () => {
54540
54501
  if (typeof window === "undefined") return;
54541
- try {
54542
- const raw = localStorage.getItem(LOCAL_STORAGE_KEYS.transactionHistory);
54543
- if (!raw) return;
54544
- const parsed = JSON.parse(raw);
54545
- const transformed = toCamelCase(parsed);
54546
- await idbSet(LOCAL_STORAGE_KEYS.transactionHistory, transformed);
54547
- localStorage.removeItem(LOCAL_STORAGE_KEYS.transactionHistory);
54548
- console.info("✅ Migrated transactionHistory from localStorage to IndexedDB");
54549
- } catch (err) {
54550
- console.warn("⚠️ Failed to migrate transactionHistory", err);
54551
- }
54502
+ const { set } = jotaiStore;
54503
+ const transactionHistoryVersion = localStorage.getItem(
54504
+ LOCAL_STORAGE_KEYS.transactionHistoryVersion
54505
+ );
54506
+ console.info(`loaded transactionHistory version ${transactionHistoryVersion}`);
54507
+ Object.values(LOCAL_STORAGE_KEYS).forEach((key) => {
54508
+ try {
54509
+ const raw = localStorage.getItem(key);
54510
+ if (!raw) return;
54511
+ const parsed = JSON.parse(raw);
54512
+ let newLocalStorageValue = toCamelCase(parsed);
54513
+ if (key === LOCAL_STORAGE_KEYS.transactionHistory) {
54514
+ newLocalStorageValue = newLocalStorageValue.filter(
54515
+ (txHistoryItem) => {
54516
+ var _a, _b, _c, _d;
54517
+ const chainId = (_b = (_a = txHistoryItem == null ? void 0 : txHistoryItem.transactionDetails) == null ? void 0 : _a[0]) == null ? void 0 : _b.chainId;
54518
+ const txHash = (_d = (_c = txHistoryItem == null ? void 0 : txHistoryItem.transactionDetails) == null ? void 0 : _c[0]) == null ? void 0 : _d.txHash;
54519
+ if (chainId !== void 0 && txHash !== void 0) {
54520
+ return true;
54521
+ }
54522
+ }
54523
+ );
54524
+ }
54525
+ if (!transactionHistoryVersion && key === LOCAL_STORAGE_KEYS.transactionHistory) {
54526
+ localStorage.setItem(key, JSON.stringify(newLocalStorageValue));
54527
+ console.info(
54528
+ `updated from transactionHistoryVersion ${transactionHistoryVersion} to ${HISTORY_VERSION.camelCase}`
54529
+ );
54530
+ set(transactionHistoryVersionAtom, HISTORY_VERSION.camelCase);
54531
+ } else if (JSON.stringify(parsed) !== JSON.stringify(newLocalStorageValue)) {
54532
+ localStorage.setItem(key, JSON.stringify(newLocalStorageValue));
54533
+ console.info(`updated old localStorage value for ${key}`);
54534
+ }
54535
+ } catch (err) {
54536
+ console.warn(`Failed to migrate localStorage key "${key}":`, err);
54537
+ }
54538
+ });
54552
54539
  };
54553
54540
  function toCamelCase(obj) {
54554
54541
  return convertKeys(obj, (key) => {
@@ -54640,7 +54627,7 @@ const SolanaProvider = ({ children }) => {
54640
54627
  };
54641
54628
  const queryClient = new QueryClient();
54642
54629
  const jotaiStore = createStore();
54643
- migrateHistoryFromLocalStorageToIndexedDB();
54630
+ migrateOldLocalStorageValues();
54644
54631
  const Widget = (props) => {
54645
54632
  return /* @__PURE__ */ jsx(Provider, { store: jotaiStore, children: /* @__PURE__ */ jsx(WidgetWithinProvider, { props }) });
54646
54633
  };
package/build/index.d.ts CHANGED
@@ -12,6 +12,7 @@ import { WalletConnectModalConfig } from '@walletconnect/modal';
12
12
  declare type Callbacks = {
13
13
  onWalletConnected?: (props: onWalletConnectedProps) => void;
14
14
  onWalletDisconnected?: (props: onWalletDisconnectedProps) => void;
15
+ onTransactionSignRequested?: (props: onTransactionSignRequestedProps) => void;
15
16
  onTransactionBroadcasted?: (props: onTransactionBroadcastedProps) => void;
16
17
  onTransactionComplete?: (props: onTransactionCompleteProps) => void;
17
18
  onTransactionFailed?: (props: onTransactionFailedProps) => void;
@@ -166,6 +167,12 @@ declare type onTransactionFailedProps = {
166
167
  error: string;
167
168
  };
168
169
 
170
+ declare type onTransactionSignRequestedProps = {
171
+ chainId: string;
172
+ signerAddress?: string;
173
+ txIndex: number;
174
+ };
175
+
169
176
  declare type onWalletConnectedProps = {
170
177
  walletName: string;
171
178
  chainIdToAddressMap?: Record<string, string>;
@@ -1,4 +1,4 @@
1
- import { g as getAugmentedNamespace, c as commonjsGlobal, a as getDefaultExportFromCjs, p as process$1 } from "./index-BRlzKaV6.js";
1
+ import { g as getAugmentedNamespace, c as commonjsGlobal, a as getDefaultExportFromCjs, p as process$1 } from "./index-B_YSz0du.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-BRlzKaV6.js";
1
+ import { W, d, l, o, r, s } from "./index-B_YSz0du.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.1",
4
+ "version": "3.12.2",
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.0",
45
+ "@skip-go/client": "1.3.1",
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",