@0xsquid/react-hooks 8.10.0 → 8.11.0

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.
Files changed (32) hide show
  1. package/dist/core/canton/cantonConnector.d.ts +2 -1
  2. package/dist/core/canton/injectedCantonProvider.d.ts +31 -0
  3. package/dist/core/connectors/bitcoin/wallets/keplr.d.ts +3 -0
  4. package/dist/core/connectors/bitcoin/wallets/phantom.d.ts +3 -1
  5. package/dist/core/connectors/bitcoin/wallets/unisat.d.ts +15 -0
  6. package/dist/core/index.d.ts +1 -1
  7. package/dist/core/types/bitcoin.d.ts +3 -0
  8. package/dist/hooks/canton/useCantonWallets.d.ts +4 -2
  9. package/dist/{index-Dzir2lUQ.js → index-BzTFES6t.js} +297 -115
  10. package/dist/index-BzTFES6t.js.map +1 -0
  11. package/dist/{index-BlB3yIoX.js → index-D5bkikGx.js} +297 -116
  12. package/dist/index-D5bkikGx.js.map +1 -0
  13. package/dist/{index.es-BPXYaraD.js → index.es-DaKI7v5_.js} +2 -2
  14. package/dist/{index.es-BPXYaraD.js.map → index.es-DaKI7v5_.js.map} +1 -1
  15. package/dist/{index.es-DwtZr7bN.js → index.es-wL3I3c3h.js} +2 -2
  16. package/dist/{index.es-DwtZr7bN.js.map → index.es-wL3I3c3h.js.map} +1 -1
  17. package/dist/index.esm.js +1 -1
  18. package/dist/index.js +2 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/{secretService-eiBnD7dI.js → secretService-BMH_eXJd.js} +2 -2
  21. package/dist/{secretService-eiBnD7dI.js.map → secretService-BMH_eXJd.js.map} +1 -1
  22. package/dist/{secretService-ICina23f.js → secretService-D70MRo5w.js} +2 -2
  23. package/dist/{secretService-ICina23f.js.map → secretService-D70MRo5w.js.map} +1 -1
  24. package/dist/services/internal/cantonService.d.ts +17 -1
  25. package/dist/{stellarService.client-VOmCOPzL.js → stellarService.client-BpCW1qZY.js} +2 -2
  26. package/dist/{stellarService.client-VOmCOPzL.js.map → stellarService.client-BpCW1qZY.js.map} +1 -1
  27. package/dist/{stellarService.client-Bjc92sC_.js → stellarService.client-DhwF4F1c.js} +2 -2
  28. package/dist/{stellarService.client-Bjc92sC_.js.map → stellarService.client-DhwF4F1c.js.map} +1 -1
  29. package/dist/tests/injectedCantonProvider.test.d.ts +1 -0
  30. package/package.json +1 -1
  31. package/dist/index-BlB3yIoX.js.map +0 -1
  32. package/dist/index-Dzir2lUQ.js.map +0 -1
@@ -3463,7 +3463,7 @@ function get$1(object, path, defaultValue) {
3463
3463
 
3464
3464
  var get_1 = get$1;
3465
3465
 
3466
- var get$2 = /*@__PURE__*/getDefaultExportFromCjs(get_1);
3466
+ var getProperty = /*@__PURE__*/getDefaultExportFromCjs(get_1);
3467
3467
 
3468
3468
  /**
3469
3469
  * The base implementation of `_.hasIn` without support for deep paths.
@@ -4739,33 +4739,6 @@ class BitcoinConnectorInvalidAccountError extends BitcoinConnectorError {
4739
4739
  }
4740
4740
  }
4741
4741
 
4742
- class KeplrConnector {
4743
- get getProvider() {
4744
- const provider = window?.bitcoin_keplr;
4745
- if (!provider) {
4746
- throw new BitcoinConnectorProviderNotFoundError("Keplr");
4747
- }
4748
- return provider;
4749
- }
4750
- async sendBTC(to, amount) {
4751
- const txHash = await this.getProvider.sendBitcoin(to, amount);
4752
- if (!txHash) {
4753
- throw new BitcoinConnectorTransactionFailedError();
4754
- }
4755
- return { txHash };
4756
- }
4757
- async requestAccount() {
4758
- const accounts = await this.getProvider.requestAccounts();
4759
- const account = accounts[0];
4760
- if (typeof account !== "string") {
4761
- throw new BitcoinConnectorInvalidAccountError();
4762
- }
4763
- return {
4764
- address: account,
4765
- };
4766
- }
4767
- }
4768
-
4769
4742
  bitcoin__namespace.initEccLib(ecc__namespace);
4770
4743
  const network = bitcoin__namespace.networks.bitcoin;
4771
4744
  const fromHexString = (hexString) => {
@@ -4854,6 +4827,53 @@ async function getTransactionStatus$1(txHash) {
4854
4827
  .then((response) => response.data);
4855
4828
  }
4856
4829
 
4830
+ class KeplrConnector {
4831
+ get getProvider() {
4832
+ const provider = window?.bitcoin_keplr;
4833
+ if (!provider) {
4834
+ throw new BitcoinConnectorProviderNotFoundError("Keplr");
4835
+ }
4836
+ return provider;
4837
+ }
4838
+ async sendBTC(to, amount) {
4839
+ const txHash = await this.getProvider.sendBitcoin(to, amount);
4840
+ if (!txHash) {
4841
+ throw new BitcoinConnectorTransactionFailedError();
4842
+ }
4843
+ return { txHash };
4844
+ }
4845
+ async requestAccount() {
4846
+ const accounts = await this.getProvider.requestAccounts();
4847
+ const account = accounts[0];
4848
+ if (typeof account !== "string") {
4849
+ throw new BitcoinConnectorInvalidAccountError();
4850
+ }
4851
+ return {
4852
+ address: account,
4853
+ };
4854
+ }
4855
+ async signPsbt(psbtHex) {
4856
+ // Keplr follows the UniSat-style Bitcoin provider API: `signPsbt` signs and,
4857
+ // with `autoFinalized` (the default), finalizes every input, returning the
4858
+ // signed PSBT as a hex string.
4859
+ // https://docs.keplr.app/api/bitcoin
4860
+ const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
4861
+ autoFinalized: true,
4862
+ });
4863
+ // Broadcast the finalized raw transaction directly rather than through
4864
+ // Keplr's `pushTx`, which proxies via Keplr's own Bitcoin indexer
4865
+ // (api-indexer-bitcoin.keplr.app) and fails when that service is down.
4866
+ const rawTxHex = bitcoin__namespace.Psbt.fromHex(signedPsbtHex)
4867
+ .extractTransaction()
4868
+ .toHex();
4869
+ const txHash = await broadcastTx(rawTxHex);
4870
+ if (!txHash) {
4871
+ throw new BitcoinConnectorTransactionFailedError();
4872
+ }
4873
+ return { txHash };
4874
+ }
4875
+ }
4876
+
4857
4877
  const MAINNET = bitcoin__namespace.networks.bitcoin;
4858
4878
  class PhantomConnector {
4859
4879
  get getProvider() {
@@ -4878,10 +4898,8 @@ class PhantomConnector {
4878
4898
  async sendBTC(to, amount) {
4879
4899
  const { address } = await this.requestAccount();
4880
4900
  const { psbtHex } = await createSendBtcPsbt(address, to, amount);
4881
- const { txId } = await this.signPsbt(psbtHex);
4882
- if (!txId)
4883
- throw new BitcoinConnectorTransactionFailedError();
4884
- return { txHash: txId };
4901
+ const { txHash } = await this.signPsbt(psbtHex);
4902
+ return { txHash };
4885
4903
  }
4886
4904
  async signPsbt(psbtHex) {
4887
4905
  const { address: paymentAddress } = await this.requestAccount();
@@ -4902,8 +4920,10 @@ class PhantomConnector {
4902
4920
  const signedPsbt = bitcoin__namespace.Psbt.fromBuffer(signedPsbtBytes);
4903
4921
  signedPsbt.finalizeAllInputs();
4904
4922
  const tx = signedPsbt.extractTransaction();
4905
- const txId = await broadcastTx(tx.toHex());
4906
- return { txId };
4923
+ const txHash = await broadcastTx(tx.toHex());
4924
+ if (!txHash)
4925
+ throw new BitcoinConnectorTransactionFailedError();
4926
+ return { txHash };
4907
4927
  }
4908
4928
  }
4909
4929
 
@@ -4932,6 +4952,21 @@ class UnisatConnector {
4932
4952
  address: account,
4933
4953
  };
4934
4954
  }
4955
+ async signPsbt(psbtHex) {
4956
+ // UniSat signs and, with `autoFinalized` (the default), finalizes every
4957
+ // input, returning the signed PSBT as a hex string.
4958
+ // https://docs.unisat.io/dev/unisat-developer-center/unisat-wallet/api-list
4959
+ const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
4960
+ autoFinalized: true,
4961
+ });
4962
+ // `pushPsbt` extracts the finalized transaction from the signed PSBT and
4963
+ // broadcasts it, returning the transaction id.
4964
+ const txHash = await this.getProvider.pushPsbt(signedPsbtHex);
4965
+ if (!txHash) {
4966
+ throw new BitcoinConnectorTransactionFailedError();
4967
+ }
4968
+ return { txHash };
4969
+ }
4935
4970
  }
4936
4971
 
4937
4972
  var XrplTransactionType;
@@ -20570,7 +20605,7 @@ const walletIconBaseUrl = "https://raw.githubusercontent.com/0xsquid/assets/main
20570
20605
  * Returns the value of the property if found, otherwise undefined.
20571
20606
  */
20572
20607
  const accessProperty = (object, path) => {
20573
- const value = get$2(object, path);
20608
+ const value = getProperty(object, path);
20574
20609
  if (value === undefined) {
20575
20610
  console.error(`Property "${path}" not found while reading object`, object);
20576
20611
  }
@@ -20898,6 +20933,16 @@ const fallbackWallets = [
20898
20933
  chrome: "https://chromewebstore.google.com/detail/console-wallet/lpnfhpbpmlobjlgkdmnjieeihjmihhjd",
20899
20934
  },
20900
20935
  },
20936
+ {
20937
+ chainType: squidTypes.ChainType.CANTON,
20938
+ id: "nightly",
20939
+ name: "Nightly",
20940
+ connectorName: "Nightly",
20941
+ icon: `${walletIconBaseUrl}/nightly.webp`,
20942
+ links: {
20943
+ chrome: "https://chromewebstore.google.com/detail/nightly/fiikommddbeccaoicoejoniammnalkfa",
20944
+ },
20945
+ },
20901
20946
  ];
20902
20947
 
20903
20948
  // Validation taken from Squid API repo
@@ -20919,6 +20964,32 @@ const isBitcoinAddressValid = (address) => {
20919
20964
  }
20920
20965
  };
20921
20966
 
20967
+ /**
20968
+ * Format a Canton connector into a Squid {@link CantonWallet}. Shared by the
20969
+ * announce-discovery and injected-provider paths.
20970
+ */
20971
+ function formatCantonWallet({ connectorId, name, icon, connector, }) {
20972
+ return {
20973
+ name,
20974
+ connectorId,
20975
+ connectorName: name,
20976
+ icon,
20977
+ windowFlag: connectorId,
20978
+ skipInstallCheck: true,
20979
+ isInstalled: () => true,
20980
+ isMultiChain: false,
20981
+ type: squidTypes.ChainType.CANTON,
20982
+ connector,
20983
+ };
20984
+ }
20985
+ /**
20986
+ * Append injected wallets that aren't already covered by an announce-discovered
20987
+ * wallet with the same connectorId (in case a wallet later does both).
20988
+ */
20989
+ function mergeInjectedCantonWallets(announced, injected) {
20990
+ const seen = new Set(announced.map((w) => w.connectorId));
20991
+ return [...announced, ...injected.filter((w) => !seen.has(w.connectorId))];
20992
+ }
20922
20993
  // Canton PartyID = address
20923
20994
  const CANTON_PARTY_ID_SEPARATOR = "::";
20924
20995
  /** Canton Coin's well-known token-standard instrument id (its address carries no id prefix). */
@@ -22894,21 +22965,21 @@ const resolveChainIdFromAsset = (asset, chains) => {
22894
22965
  };
22895
22966
  const getConfigWithDefaults = (config) => {
22896
22967
  return {
22897
- integratorId: get$2(config, "integratorId", defaultConfigValues.integratorId),
22898
- slippage: get$2(config, "slippage", defaultConfigValues.slippage),
22899
- collectFees: get$2(config, "collectFees", defaultConfigValues.collectFees),
22900
- apiUrl: get$2(config, "apiUrl", defaultConfigValues.apiUrl),
22901
- priceImpactWarnings: get$2(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
22902
- initialAssets: get$2(config, "initialAssets", defaultConfigValues.initialAssets),
22903
- defaultTokensPerChain: get$2(config, "defaultTokensPerChain", defaultConfigValues.defaultTokensPerChain),
22904
- loadPreviousStateFromLocalStorage: get$2(config, "loadPreviousStateFromLocalStorage", defaultConfigValues.loadPreviousStateFromLocalStorage),
22905
- availableChains: get$2(config, "availableChains", defaultConfigValues.availableChains),
22906
- availableTokens: get$2(config, "availableTokens", defaultConfigValues.availableTokens),
22907
- disabledChains: get$2(config, "disabledChains", defaultConfigValues.disabledChains),
22908
- degenMode: get$2(config, "degenMode", defaultConfigValues.degenMode),
22909
- preHook: get$2(config, "preHook", defaultConfigValues.preHook),
22910
- postHook: get$2(config, "postHook", defaultConfigValues.postHook),
22911
- overrideGasRefundAddress: get$2(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
22968
+ integratorId: getProperty(config, "integratorId", defaultConfigValues.integratorId),
22969
+ slippage: getProperty(config, "slippage", defaultConfigValues.slippage),
22970
+ collectFees: getProperty(config, "collectFees", defaultConfigValues.collectFees),
22971
+ apiUrl: getProperty(config, "apiUrl", defaultConfigValues.apiUrl),
22972
+ priceImpactWarnings: getProperty(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
22973
+ initialAssets: getProperty(config, "initialAssets", defaultConfigValues.initialAssets),
22974
+ defaultTokensPerChain: getProperty(config, "defaultTokensPerChain", defaultConfigValues.defaultTokensPerChain),
22975
+ loadPreviousStateFromLocalStorage: getProperty(config, "loadPreviousStateFromLocalStorage", defaultConfigValues.loadPreviousStateFromLocalStorage),
22976
+ availableChains: getProperty(config, "availableChains", defaultConfigValues.availableChains),
22977
+ availableTokens: getProperty(config, "availableTokens", defaultConfigValues.availableTokens),
22978
+ disabledChains: getProperty(config, "disabledChains", defaultConfigValues.disabledChains),
22979
+ degenMode: getProperty(config, "degenMode", defaultConfigValues.degenMode),
22980
+ preHook: getProperty(config, "preHook", defaultConfigValues.preHook),
22981
+ postHook: getProperty(config, "postHook", defaultConfigValues.postHook),
22982
+ overrideGasRefundAddress: getProperty(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
22912
22983
  };
22913
22984
  };
22914
22985
  const randomIntFromInterval = (min, max) => {
@@ -23605,7 +23676,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23605
23676
  };
23606
23677
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23607
23678
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23608
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-ICina23f.js'); });
23679
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-D70MRo5w.js'); });
23609
23680
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23610
23681
  };
23611
23682
  function getTokenAssetsKey(token) {
@@ -26836,14 +26907,16 @@ class CantonBrowserConnector {
26836
26907
  client;
26837
26908
  listeners = { connect: new Set(), disconnect: new Set() };
26838
26909
  _accounts = [];
26839
- constructor(provider, win = window) {
26910
+ constructor(provider, win = window, client) {
26840
26911
  this.providerId = provider.id;
26841
26912
  this.name = provider.name;
26842
26913
  this.target = provider.target ?? provider.id;
26843
- this.client = dapp.createCantonClient(new dapp.WindowTransport(win, {
26844
- target: this.target,
26845
- timeout: REQUEST_TIMEOUT_MS,
26846
- }));
26914
+ this.client =
26915
+ client ??
26916
+ dapp.createCantonClient(new dapp.WindowTransport(win, {
26917
+ target: this.target,
26918
+ timeout: REQUEST_TIMEOUT_MS,
26919
+ }));
26847
26920
  }
26848
26921
  get accounts() {
26849
26922
  return this._accounts;
@@ -26945,44 +27018,116 @@ async function discoverCantonProviders(timeoutMs = DEFAULT_DISCOVERY_TIMEOUT_MS,
26945
27018
  }
26946
27019
 
26947
27020
  /**
26948
- * Discovers Canton browser-extension wallets via the CIP-103 announce protocol
26949
- * (on mount and on window focus) and maps each to a {@link CantonWallet}.
27021
+ * CIP-103 wallets that expose their provider as an injected `window` global
27022
+ * instead of participating in the `canton:announceProvider` discovery protocol.
27023
+ * Add an entry to support a new one.
27024
+ */
27025
+ const INJECTED_CANTON_WALLETS = [
27026
+ {
27027
+ connectorId: "nightly",
27028
+ name: "Nightly",
27029
+ icon: `${walletIconBaseUrl}/nightly.webp`,
27030
+ windowPath: "nightly.canton",
27031
+ },
27032
+ ];
27033
+ /**
27034
+ * Adapts an injected CIP-103 `SpliceProvider` (the normative `request` API) to
27035
+ * the {@link CantonClient} surface consumed by `CantonBrowserConnector`, so
27036
+ * injected wallets reuse the same connector as announce-discovered ones.
27037
+ */
27038
+ function cantonClientFromSpliceProvider(provider) {
27039
+ return {
27040
+ status: () => provider.request({ method: "status" }),
27041
+ connect: () => provider.request({ method: "connect" }),
27042
+ disconnect: () => provider.request({ method: "disconnect" }),
27043
+ isConnected: () => provider.request({ method: "isConnected" }),
27044
+ getActiveNetwork: () => provider.request({ method: "getActiveNetwork" }),
27045
+ listAccounts: () => provider.request({ method: "listAccounts" }),
27046
+ getPrimaryAccount: () => provider.request({ method: "getPrimaryAccount" }),
27047
+ prepareExecute: (params) => provider.request({ method: "prepareExecute", params }),
27048
+ prepareExecuteAndWait: (params) => provider.request({ method: "prepareExecuteAndWait", params }),
27049
+ signMessage: (params) => provider.request({ method: "signMessage", params }),
27050
+ ledgerApi: (params) => provider.request({ method: "ledgerApi", params }),
27051
+ };
27052
+ }
27053
+ /**
27054
+ * Detect installed injected Canton wallets by walking each registered
27055
+ * `windowPath`, mirroring the `definedInWindow` install check used for other
27056
+ * non-autodiscovered wallets.
27057
+ */
27058
+ function discoverInjectedCantonWallets(win) {
27059
+ const source = (typeof window !== "undefined" ? window : undefined);
27060
+ if (!source)
27061
+ return [];
27062
+ return INJECTED_CANTON_WALLETS.flatMap((config) => {
27063
+ const provider = getProperty(source, config.windowPath);
27064
+ if (!provider || typeof provider.request !== "function")
27065
+ return [];
27066
+ return [{ config, provider }];
27067
+ });
27068
+ }
27069
+
27070
+ /**
27071
+ * Discovers Canton browser-extension wallets and maps each to a
27072
+ * {@link CantonWallet}: CIP-103 announce-protocol wallets (on mount and on
27073
+ * window focus), plus injected wallets that ship the CIP-103 RPC surface as a
27074
+ * `window` global instead of announcing (see `INJECTED_CANTON_WALLETS`).
26950
27075
  */
26951
27076
  function useCantonWallets() {
26952
27077
  const [wallets, setWallets] = React.useState([]);
26953
- const connectorCache = React.useRef(new Map());
26954
- const toWallet = React.useCallback((provider) => {
26955
- let connector = connectorCache.current.get(provider.id);
27078
+ const announcedCache = React.useRef(new Map());
27079
+ const injectedCache = React.useRef(new Map());
27080
+ const toAnnouncedWallet = React.useCallback((provider) => {
27081
+ let connector = announcedCache.current.get(provider.id);
26956
27082
  if (!connector) {
26957
27083
  connector = new CantonBrowserConnector(provider);
26958
- connectorCache.current.set(provider.id, connector);
27084
+ announcedCache.current.set(provider.id, connector);
26959
27085
  }
26960
- return {
26961
- name: provider.name,
27086
+ return formatCantonWallet({
26962
27087
  connectorId: provider.id,
26963
- connectorName: provider.name,
27088
+ name: provider.name,
26964
27089
  icon: provider.icon,
26965
- windowFlag: provider.id,
26966
- skipInstallCheck: true,
26967
- isInstalled: () => true,
26968
- isMultiChain: false,
26969
- type: squidTypes.ChainType.CANTON,
26970
27090
  connector,
26971
- };
27091
+ });
27092
+ }, []);
27093
+ const toInjectedWallet = React.useCallback(({ config, provider }) => {
27094
+ // Rebuild if the wallet re-injects a new provider object (e.g. extension
27095
+ // reload): the cached connector closes over the previous provider.
27096
+ let entry = injectedCache.current.get(config.connectorId);
27097
+ if (!entry || entry.provider !== provider) {
27098
+ entry = {
27099
+ connector: new CantonBrowserConnector({ id: config.connectorId, name: config.name, icon: config.icon }, window, cantonClientFromSpliceProvider(provider)),
27100
+ provider,
27101
+ };
27102
+ injectedCache.current.set(config.connectorId, entry);
27103
+ }
27104
+ return formatCantonWallet({
27105
+ connectorId: config.connectorId,
27106
+ name: config.name,
27107
+ icon: config.icon,
27108
+ connector: entry.connector,
27109
+ });
26972
27110
  }, []);
26973
27111
  const refresh = React.useCallback(async () => {
26974
27112
  if (typeof window === "undefined")
26975
27113
  return;
26976
- const providers = await discoverCantonProviders();
26977
- setWallets(providers.map(toWallet));
26978
- }, [toWallet]);
27114
+ const announced = (await discoverCantonProviders()).map(toAnnouncedWallet);
27115
+ const injected = discoverInjectedCantonWallets().map(toInjectedWallet);
27116
+ setWallets(mergeInjectedCantonWallets(announced, injected));
27117
+ }, [toAnnouncedWallet, toInjectedWallet]);
26979
27118
  React.useEffect(() => {
26980
27119
  refresh();
26981
27120
  if (typeof window === "undefined")
26982
- return;
27121
+ return undefined;
26983
27122
  const onFocus = () => refresh();
26984
27123
  window.addEventListener("focus", onFocus);
26985
- return () => window.removeEventListener("focus", onFocus);
27124
+ // Extensions may inject their global shortly after mount; re-check a couple
27125
+ // of times so late injection surfaces without a focus change.
27126
+ const retries = [500, 1500].map((ms) => window.setTimeout(refresh, ms));
27127
+ return () => {
27128
+ window.removeEventListener("focus", onFocus);
27129
+ retries.forEach((id) => window.clearTimeout(id));
27130
+ };
26986
27131
  }, [refresh]);
26987
27132
  return { wallets };
26988
27133
  }
@@ -27279,7 +27424,7 @@ function useStellarWallets() {
27279
27424
  try {
27280
27425
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
27281
27426
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
27282
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-Bjc92sC_.js'); });
27427
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-DhwF4F1c.js'); });
27283
27428
  const modules = [...initializeAllModules(), new LedgerModule()];
27284
27429
  const promises = modules.map(async (module) => {
27285
27430
  const isAvailable = await module.isAvailable();
@@ -30738,7 +30883,7 @@ function hederaWalletConnect(parameters) {
30738
30883
  const optionalChains = config.chains.map((x) => x.id);
30739
30884
  if (!optionalChains.length)
30740
30885
  return;
30741
- const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-BPXYaraD.js'); });
30886
+ const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-DaKI7v5_.js'); });
30742
30887
  const rawProvider = await EthereumProvider.init({
30743
30888
  ...restParameters,
30744
30889
  disableProviderPing: true,
@@ -37465,47 +37610,83 @@ const useExecuteTransaction = (squidRoute) => {
37465
37610
  }
37466
37611
  });
37467
37612
  const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
37468
- const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
37469
- if (!depositAddress) {
37470
- throw new Error(`Invalid deposit address: ${depositAddress}`);
37471
- }
37472
- if (!sendAmount) {
37473
- throw new Error(`Invalid send amount: ${sendAmount}`);
37613
+ if (!bitcoinSigner || !route?.transactionRequest) {
37614
+ throw new Error("Need all parameters");
37474
37615
  }
37475
- const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
37476
- await changeNetworkIfNeeded.mutateAsync();
37477
- if (allParamsValid) {
37478
- dispatchSignatureRequestEvent(route);
37479
- const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
37480
- if (txHash) {
37481
- resetQueriesAfterTxSigned();
37616
+ switch (route.transactionRequest.type) {
37617
+ case squidTypes.SquidDataType.ChainflipDepositAddress: {
37618
+ const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
37619
+ const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
37620
+ if (!allParamsValid) {
37621
+ throw new Error("Need all parameters");
37622
+ }
37623
+ await changeNetworkIfNeeded.mutateAsync();
37624
+ dispatchSignatureRequestEvent(route);
37625
+ const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
37626
+ if (txHash) {
37627
+ resetQueriesAfterTxSigned();
37628
+ }
37629
+ // Dispatch event so it can be listened from outside the widget
37630
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
37631
+ if (route.transactionRequest) {
37632
+ const txParams = setTransactionState({
37633
+ route,
37634
+ txHash,
37635
+ // When bridging from Bitcoin we need to send the chainflipId to the status endpoint
37636
+ // instead of the Bitcoin transaction hash
37637
+ transactionIdForStatus: statusTrackingId,
37638
+ userAddress: sourceUserAddress,
37639
+ status: exports.TransactionStatus.INITIAL_LOADING,
37640
+ sourceStatus: exports.TransactionStatus.ONGOING,
37641
+ axelarUrl: undefined,
37642
+ id,
37643
+ });
37644
+ if (txParams) {
37645
+ addSwapTransaction({
37646
+ ...txParams,
37647
+ params: route.params,
37648
+ estimate: route.estimate,
37649
+ });
37650
+ }
37651
+ }
37652
+ break;
37482
37653
  }
37483
- // Dispatch event so it can be listened from outside the widget
37484
- WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
37485
- if (route.transactionRequest) {
37486
- const txParams = setTransactionState({
37487
- route,
37488
- txHash,
37489
- // When bridging from Bitcoin we need to send the chainflipId to the status endpoint
37490
- // instead of the Bitcoin transaction hash
37491
- transactionIdForStatus: statusTrackingId,
37492
- userAddress: sourceUserAddress,
37493
- status: exports.TransactionStatus.INITIAL_LOADING,
37494
- sourceStatus: exports.TransactionStatus.ONGOING,
37495
- axelarUrl: undefined,
37496
- id,
37497
- });
37498
- if (txParams) {
37499
- addSwapTransaction({
37500
- ...txParams,
37501
- params: route.params,
37502
- estimate: route.estimate,
37654
+ case squidTypes.SquidDataType.DepositAddressCalldata: {
37655
+ if (!isOnChainTxData(route.transactionRequest)) {
37656
+ throw new Error("Invalid route data");
37657
+ }
37658
+ const { data: transactionHex } = route.transactionRequest;
37659
+ await changeNetworkIfNeeded.mutateAsync();
37660
+ dispatchSignatureRequestEvent(route);
37661
+ const { txHash } = await bitcoinSigner.signPsbt(transactionHex);
37662
+ if (txHash) {
37663
+ resetQueriesAfterTxSigned();
37664
+ }
37665
+ // Dispatch event so it can be listened from outside the widget
37666
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
37667
+ if (route.transactionRequest) {
37668
+ const txParams = setTransactionState({
37669
+ route,
37670
+ txHash,
37671
+ userAddress: sourceUserAddress,
37672
+ status: exports.TransactionStatus.INITIAL_LOADING,
37673
+ sourceStatus: exports.TransactionStatus.ONGOING,
37674
+ axelarUrl: undefined,
37675
+ id,
37503
37676
  });
37677
+ if (txParams) {
37678
+ addSwapTransaction({
37679
+ ...txParams,
37680
+ params: route.params,
37681
+ estimate: route.estimate,
37682
+ });
37683
+ }
37504
37684
  }
37685
+ break;
37686
+ }
37687
+ default: {
37688
+ throw new Error(`Unhandled route type ${route.transactionRequest.type}`);
37505
37689
  }
37506
- }
37507
- else {
37508
- throw new Error("Need all parameters");
37509
37690
  }
37510
37691
  });
37511
37692
  const swapMutationXrpl = reactQuery.useMutation(async ({ id, route }) => {
@@ -38811,6 +38992,7 @@ exports.isXionSmartContractAddress = isXionSmartContractAddress;
38811
38992
  exports.isXrplAddressValid = isXrplAddressValid;
38812
38993
  exports.mergeWallets = mergeWallets;
38813
38994
  exports.nativeBitcoinTokenAddress = nativeBitcoinTokenAddress;
38995
+ exports.nativeCantonTokenAddress = nativeCantonTokenAddress;
38814
38996
  exports.nativeCosmosTokenAddress = nativeCosmosTokenAddress;
38815
38997
  exports.nativeEvmTokenAddress = nativeEvmTokenAddress;
38816
38998
  exports.nativeSolanaTokenAddress = nativeSolanaTokenAddress;
@@ -38932,4 +39114,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
38932
39114
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
38933
39115
  exports.walletIconBaseUrl = walletIconBaseUrl;
38934
39116
  exports.walletSupportsChainType = walletSupportsChainType;
38935
- //# sourceMappingURL=index-Dzir2lUQ.js.map
39117
+ //# sourceMappingURL=index-BzTFES6t.js.map