@0xsquid/react-hooks 8.0.0-beta.0 → 8.0.0-beta.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.
@@ -31,7 +31,7 @@ var protoSigning = require('@cosmjs/proto-signing');
31
31
  var transactions = require('@mysten/sui/transactions');
32
32
  var connectors = require('wagmi/connectors');
33
33
  var cosmwasmStargate = require('@cosmjs/cosmwasm-stargate');
34
- var stargate$1 = require('@injectivelabs/sdk-ts/dist/cjs/core/stargate');
34
+ var index_js = require('@injectivelabs/sdk-ts/dist/cjs/core/stargate/index.js');
35
35
  var sdk = require('@0xsquid/sdk');
36
36
  var chains$1 = require('viem/chains');
37
37
 
@@ -5728,7 +5728,7 @@ class WalletConnectModal {
5728
5728
  }
5729
5729
  async initUi() {
5730
5730
  if (typeof window !== "undefined") {
5731
- await Promise.resolve().then(function () { return require('./index-CoxuUJzG.js'); });
5731
+ await Promise.resolve().then(function () { return require('./index-BT_PJ0yw.js'); });
5732
5732
  const modal = document.createElement("wcm-modal");
5733
5733
  document.body.insertAdjacentElement("beforeend", modal);
5734
5734
  OptionsCtrl.setIsUiLoaded(true);
@@ -26983,12 +26983,12 @@ const is404Error = (error) => {
26983
26983
  return false;
26984
26984
  };
26985
26985
 
26986
- var HistoryTxType;
26986
+ exports.HistoryTxType = void 0;
26987
26987
  (function (HistoryTxType) {
26988
26988
  HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
26989
26989
  HistoryTxType[HistoryTxType["BUY"] = 1] = "BUY";
26990
26990
  HistoryTxType[HistoryTxType["SEND"] = 2] = "SEND";
26991
- })(HistoryTxType || (HistoryTxType = {}));
26991
+ })(exports.HistoryTxType || (exports.HistoryTxType = {}));
26992
26992
 
26993
26993
  var TransactionType;
26994
26994
  (function (TransactionType) {
@@ -27232,11 +27232,11 @@ function isChainflipBridgeTransaction(actions = []) {
27232
27232
  }
27233
27233
  function getHistoryTransactionId(tx) {
27234
27234
  switch (tx.txType) {
27235
- case HistoryTxType.SWAP:
27235
+ case exports.HistoryTxType.SWAP:
27236
27236
  return tx.data.transactionId;
27237
- case HistoryTxType.BUY:
27237
+ case exports.HistoryTxType.BUY:
27238
27238
  return tx.data.orderId;
27239
- case HistoryTxType.SEND:
27239
+ case exports.HistoryTxType.SEND:
27240
27240
  return tx.data.hash;
27241
27241
  }
27242
27242
  }
@@ -28178,7 +28178,7 @@ const filterViewableTokens = (tokens, config) => {
28178
28178
  };
28179
28179
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
28180
28180
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
28181
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-C6ack504.js'); });
28181
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-CgX8qkVs.js'); });
28182
28182
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
28183
28183
  };
28184
28184
  function getTokenAssetsKey(token) {
@@ -29752,10 +29752,10 @@ const useHistoryStore = zustand.create(middleware.persist((set, get) => ({
29752
29752
  },
29753
29753
  replaceTransactionStatus: (params) => {
29754
29754
  switch (params.txType) {
29755
- case HistoryTxType.SWAP: {
29755
+ case exports.HistoryTxType.SWAP: {
29756
29756
  set((state) => ({
29757
29757
  transactions: state.transactions.map((tx) => {
29758
- if (tx.txType !== HistoryTxType.SWAP)
29758
+ if (tx.txType !== exports.HistoryTxType.SWAP)
29759
29759
  return tx;
29760
29760
  // TODO: do we need this comparison?
29761
29761
  return compareTransactionIds(params.transactionId, tx.data.transactionId)
@@ -29772,10 +29772,10 @@ const useHistoryStore = zustand.create(middleware.persist((set, get) => ({
29772
29772
  }));
29773
29773
  break;
29774
29774
  }
29775
- case HistoryTxType.BUY: {
29775
+ case exports.HistoryTxType.BUY: {
29776
29776
  set((state) => ({
29777
29777
  transactions: state.transactions.map((tx) => {
29778
- if (tx.txType !== HistoryTxType.BUY ||
29778
+ if (tx.txType !== exports.HistoryTxType.BUY ||
29779
29779
  tx.data.orderId !== params.orderId) {
29780
29780
  return tx;
29781
29781
  }
@@ -29791,10 +29791,10 @@ const useHistoryStore = zustand.create(middleware.persist((set, get) => ({
29791
29791
  }));
29792
29792
  break;
29793
29793
  }
29794
- case HistoryTxType.SEND: {
29794
+ case exports.HistoryTxType.SEND: {
29795
29795
  set((state) => ({
29796
29796
  transactions: state.transactions.map((tx) => {
29797
- if (tx.txType !== HistoryTxType.SEND ||
29797
+ if (tx.txType !== exports.HistoryTxType.SEND ||
29798
29798
  tx.data.hash !== params.hash) {
29799
29799
  return tx;
29800
29800
  }
@@ -29823,9 +29823,9 @@ const useHistoryStore = zustand.create(middleware.persist((set, get) => ({
29823
29823
  }
29824
29824
  },
29825
29825
  replaceTransactionAtNonce: ({ fromAddress, newTx, nonce }) => {
29826
- if (newTx.txType === HistoryTxType.SWAP) {
29826
+ if (newTx.txType === exports.HistoryTxType.SWAP) {
29827
29827
  set((state) => {
29828
- const index = state.transactions.findIndex((tx) => tx.txType === HistoryTxType.SWAP &&
29828
+ const index = state.transactions.findIndex((tx) => tx.txType === exports.HistoryTxType.SWAP &&
29829
29829
  tx.data.nonce === nonce &&
29830
29830
  tx.data.fromAddress === fromAddress);
29831
29831
  if (index !== -1) {
@@ -29857,7 +29857,7 @@ const useHistoryStore = zustand.create(middleware.persist((set, get) => ({
29857
29857
  const v0State = persistedState;
29858
29858
  return {
29859
29859
  transactions: v0State.transactions.map((v0Tx) => ({
29860
- txType: HistoryTxType.SWAP,
29860
+ txType: exports.HistoryTxType.SWAP,
29861
29861
  data: v0Tx,
29862
29862
  })),
29863
29863
  };
@@ -30073,7 +30073,7 @@ const createTransactionStatusConfig = ({ transactionId, walletAddress, providerI
30073
30073
  onSuccess: (data) => {
30074
30074
  if (data) {
30075
30075
  replaceTransactionStatus({
30076
- txType: HistoryTxType.BUY,
30076
+ txType: exports.HistoryTxType.BUY,
30077
30077
  orderId: transactionId,
30078
30078
  status: data.status,
30079
30079
  transactionHash: data.transactionHash,
@@ -30082,7 +30082,7 @@ const createTransactionStatusConfig = ({ transactionId, walletAddress, providerI
30082
30082
  },
30083
30083
  onError: () => {
30084
30084
  replaceTransactionStatus({
30085
- txType: HistoryTxType.BUY,
30085
+ txType: exports.HistoryTxType.BUY,
30086
30086
  orderId: transactionId,
30087
30087
  status: "failed",
30088
30088
  transactionHash: undefined,
@@ -30200,7 +30200,7 @@ const useExecuteFiatQuote = () => {
30200
30200
  timestamp: Date.now(),
30201
30201
  providerId: executeQuoteRequest.providerId,
30202
30202
  },
30203
- txType: HistoryTxType.BUY,
30203
+ txType: exports.HistoryTxType.BUY,
30204
30204
  });
30205
30205
  },
30206
30206
  });
@@ -30223,7 +30223,7 @@ const useFiatOnRampTxStatus = (transactionId, walletAddress, providerId) => {
30223
30223
  * Tracks all pending fiat transactions.
30224
30224
  */
30225
30225
  const useFiatTransactions = () => {
30226
- const transactions = useHistoryStore((state) => state.transactions.filter((tx) => tx.txType === HistoryTxType.BUY));
30226
+ const transactions = useHistoryStore((state) => state.transactions.filter((tx) => tx.txType === exports.HistoryTxType.BUY));
30227
30227
  const replaceTransactionStatus = useHistoryStore((state) => state.replaceTransactionStatus);
30228
30228
  const pendingTransactions = React.useMemo(() => transactions?.filter((tx) => !FINAL_TRANSACTION_STATUSES.includes(tx.data.status)) ?? [], [transactions]);
30229
30229
  const queries = reactQuery.useQueries({
@@ -30654,20 +30654,20 @@ const getTransactionEndStatus = ({ statusResponse, }) => {
30654
30654
  };
30655
30655
  function isHistoryTransactionPending({ txType, data, }) {
30656
30656
  switch (txType) {
30657
- case HistoryTxType.SWAP:
30657
+ case exports.HistoryTxType.SWAP:
30658
30658
  const swapTxPendingStatuses = [
30659
30659
  exports.TransactionStatus.INITIAL_LOADING,
30660
30660
  exports.TransactionStatus.ONGOING,
30661
30661
  exports.TransactionStatus.PENDING,
30662
30662
  ];
30663
30663
  return swapTxPendingStatuses.includes(data.status);
30664
- case HistoryTxType.BUY:
30664
+ case exports.HistoryTxType.BUY:
30665
30665
  const fiatTxPendingStatuses = [
30666
30666
  "awaiting_payment",
30667
30667
  "processing",
30668
30668
  ];
30669
30669
  return fiatTxPendingStatuses.includes(data.status);
30670
- case HistoryTxType.SEND:
30670
+ case exports.HistoryTxType.SEND:
30671
30671
  const sendTxPendingStatuses = [
30672
30672
  exports.SendTransactionStatus.ONGOING,
30673
30673
  ];
@@ -30676,31 +30676,31 @@ function isHistoryTransactionPending({ txType, data, }) {
30676
30676
  }
30677
30677
  function isHistoryTransactionFailed({ txType, data, }) {
30678
30678
  switch (txType) {
30679
- case HistoryTxType.SWAP:
30679
+ case exports.HistoryTxType.SWAP:
30680
30680
  return data.status === exports.TransactionStatus.ERROR;
30681
- case HistoryTxType.BUY:
30681
+ case exports.HistoryTxType.BUY:
30682
30682
  return data.status === "failed";
30683
- case HistoryTxType.SEND:
30683
+ case exports.HistoryTxType.SEND:
30684
30684
  return data.status === exports.SendTransactionStatus.ERROR;
30685
30685
  }
30686
30686
  }
30687
30687
  function isHistoryTransactionWarning({ txType, data, }) {
30688
30688
  switch (txType) {
30689
- case HistoryTxType.SWAP:
30689
+ case exports.HistoryTxType.SWAP:
30690
30690
  return data.status === exports.TransactionStatus.WARNING;
30691
- case HistoryTxType.BUY:
30692
- case HistoryTxType.SEND:
30691
+ case exports.HistoryTxType.BUY:
30692
+ case exports.HistoryTxType.SEND:
30693
30693
  // there's no warning status for buy or send transactions
30694
30694
  return false;
30695
30695
  }
30696
30696
  }
30697
30697
  function isHistoryTransactionEnded({ txType, data, }) {
30698
30698
  switch (txType) {
30699
- case HistoryTxType.SWAP:
30699
+ case exports.HistoryTxType.SWAP:
30700
30700
  return transactionEndStatuses.includes(data.status);
30701
- case HistoryTxType.BUY:
30701
+ case exports.HistoryTxType.BUY:
30702
30702
  return FINAL_TRANSACTION_STATUSES.includes(data.status);
30703
- case HistoryTxType.SEND:
30703
+ case exports.HistoryTxType.SEND:
30704
30704
  const sendTxEndedStatuses = [
30705
30705
  exports.SendTransactionStatus.SUCCESS,
30706
30706
  exports.SendTransactionStatus.ERROR,
@@ -35675,7 +35675,7 @@ function useSendTransaction({ to, amount, token, chain, }) {
35675
35675
  queryClient.invalidateQueries(getPrefixKey(QueryKeys.Balance));
35676
35676
  setTransactionState(variables.id, tx);
35677
35677
  persistTransaction({
35678
- txType: HistoryTxType.SEND,
35678
+ txType: exports.HistoryTxType.SEND,
35679
35679
  data: {
35680
35680
  amount: tx.amount,
35681
35681
  token: {
@@ -35880,7 +35880,7 @@ const useHistory = (txType) => {
35880
35880
  actions: simplifiedActions,
35881
35881
  };
35882
35882
  return {
35883
- txType: HistoryTxType.SWAP,
35883
+ txType: exports.HistoryTxType.SWAP,
35884
35884
  data: swapTxData,
35885
35885
  };
35886
35886
  }, []);
@@ -35892,7 +35892,7 @@ const useHistory = (txType) => {
35892
35892
  }, [parseSwapTransaction, persistTransaction]);
35893
35893
  const replaceSwapTransactionStatus = React.useCallback((params) => {
35894
35894
  replaceTransactionStatus({
35895
- txType: HistoryTxType.SWAP,
35895
+ txType: exports.HistoryTxType.SWAP,
35896
35896
  status: params.status,
35897
35897
  transactionId: params.transactionId,
35898
35898
  statusResponse: formatSwapTxStatusResponseForStorage(params.statusResponse),
@@ -35947,7 +35947,7 @@ const useAllTransactionsStatus = ({ enabled }) => {
35947
35947
  const onrampService = new OnrampService();
35948
35948
  const statusQueries = pendingTransactions.map(({ txType, data }) => {
35949
35949
  switch (txType) {
35950
- case HistoryTxType.SWAP: {
35950
+ case exports.HistoryTxType.SWAP: {
35951
35951
  return {
35952
35952
  queryKey: keys().swapTransactionStatus(data.transactionId),
35953
35953
  queryFn: async () => {
@@ -35980,7 +35980,7 @@ const useAllTransactionsStatus = ({ enabled }) => {
35980
35980
  },
35981
35981
  };
35982
35982
  }
35983
- case HistoryTxType.BUY:
35983
+ case exports.HistoryTxType.BUY:
35984
35984
  return {
35985
35985
  queryFn: () => onrampService.getTransactionStatus(data.orderId, data.toAddress, data.providerId),
35986
35986
  queryKey: keys().fiatToCryptoStatus(data.orderId),
@@ -35998,12 +35998,12 @@ const useAllTransactionsStatus = ({ enabled }) => {
35998
35998
  orderId: data.orderId,
35999
35999
  status: statusData.status,
36000
36000
  transactionHash: statusData.transactionHash,
36001
- txType: HistoryTxType.BUY,
36001
+ txType: exports.HistoryTxType.BUY,
36002
36002
  });
36003
36003
  },
36004
36004
  onError: () => {
36005
36005
  replaceTransactionStatus({
36006
- txType: HistoryTxType.BUY,
36006
+ txType: exports.HistoryTxType.BUY,
36007
36007
  orderId: data.orderId,
36008
36008
  status: "failed",
36009
36009
  transactionHash: undefined,
@@ -36011,7 +36011,7 @@ const useAllTransactionsStatus = ({ enabled }) => {
36011
36011
  },
36012
36012
  enabled: true,
36013
36013
  };
36014
- case HistoryTxType.SEND:
36014
+ case exports.HistoryTxType.SEND:
36015
36015
  return {
36016
36016
  queryKey: keys().sendTransactionStatus(data.hash, data.token.chainId),
36017
36017
  queryFn: async () => {
@@ -36028,7 +36028,7 @@ const useAllTransactionsStatus = ({ enabled }) => {
36028
36028
  onSuccess: (status) => {
36029
36029
  if (status !== exports.SendTransactionStatus.ONGOING) {
36030
36030
  replaceTransactionStatus({
36031
- txType: HistoryTxType.SEND,
36031
+ txType: exports.HistoryTxType.SEND,
36032
36032
  status,
36033
36033
  hash: data.hash,
36034
36034
  });
@@ -36036,7 +36036,7 @@ const useAllTransactionsStatus = ({ enabled }) => {
36036
36036
  },
36037
36037
  onError: () => {
36038
36038
  replaceTransactionStatus({
36039
- txType: HistoryTxType.SEND,
36039
+ txType: exports.HistoryTxType.SEND,
36040
36040
  status: exports.SendTransactionStatus.ERROR,
36041
36041
  hash: data.hash,
36042
36042
  });
@@ -39589,7 +39589,7 @@ const useExecuteTransaction = (squidRoute) => {
39589
39589
  return null;
39590
39590
  switch (fromChain.chainId) {
39591
39591
  case CHAIN_IDS.INJECTIVE:
39592
- return stargate$1.InjectiveSigningStargateClient.connectWithSigner(rpc, cosmosSigner);
39592
+ return index_js.InjectiveSigningStargateClient.connectWithSigner(rpc, cosmosSigner);
39593
39593
  default: {
39594
39594
  const cosmosClient = await getCosmosSigningClient({
39595
39595
  chainRpc: rpc,
@@ -40394,7 +40394,7 @@ function useSendTransactionStatus({ chain, txHash, }) {
40394
40394
  const findTransaction = useHistoryStore((state) => state.findTransaction);
40395
40395
  const currentHistoryItem = findTransaction({
40396
40396
  transactionId: txHash,
40397
- txType: HistoryTxType.SEND,
40397
+ txType: exports.HistoryTxType.SEND,
40398
40398
  });
40399
40399
  const { data: status } = reactQuery.useQuery({
40400
40400
  queryKey: keys().sendTransactionStatus(txHash, chain?.chainId),
@@ -40410,7 +40410,7 @@ function useSendTransactionStatus({ chain, txHash, }) {
40410
40410
  setIsTransactionComplete(txStatus !== exports.SendTransactionStatus.ONGOING);
40411
40411
  if (txStatus != null && !!txHash) {
40412
40412
  replaceTransactionStatus({
40413
- txType: HistoryTxType.SEND,
40413
+ txType: exports.HistoryTxType.SEND,
40414
40414
  status: txStatus,
40415
40415
  hash: txHash,
40416
40416
  });
@@ -40420,7 +40420,7 @@ function useSendTransactionStatus({ chain, txHash, }) {
40420
40420
  setIsTransactionComplete(true);
40421
40421
  if (txHash) {
40422
40422
  replaceTransactionStatus({
40423
- txType: HistoryTxType.SEND,
40423
+ txType: exports.HistoryTxType.SEND,
40424
40424
  status: exports.SendTransactionStatus.ERROR,
40425
40425
  hash: txHash,
40426
40426
  });
@@ -40435,7 +40435,7 @@ function useSendTransactionStatus({ chain, txHash, }) {
40435
40435
  !!currentHistoryItem &&
40436
40436
  !isHistoryTransactionEnded({
40437
40437
  data: currentHistoryItem?.data,
40438
- txType: HistoryTxType.SEND,
40438
+ txType: exports.HistoryTxType.SEND,
40439
40439
  }),
40440
40440
  });
40441
40441
  return {
@@ -40456,7 +40456,7 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
40456
40456
  const { getChainType } = useSquidChains();
40457
40457
  const currentHistoryItem = React.useMemo(() => findTransaction({
40458
40458
  transactionId: transaction?.transactionId,
40459
- txType: HistoryTxType.SWAP,
40459
+ txType: exports.HistoryTxType.SWAP,
40460
40460
  }), [findTransaction, transaction?.transactionId]);
40461
40461
  /**
40462
40462
  * Transaction status endpoint
@@ -40483,7 +40483,7 @@ const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocu
40483
40483
  !!currentHistoryItem &&
40484
40484
  !isHistoryTransactionEnded({
40485
40485
  data: currentHistoryItem?.data,
40486
- txType: HistoryTxType.SWAP,
40486
+ txType: exports.HistoryTxType.SWAP,
40487
40487
  }),
40488
40488
  refetchInterval(statusResponse) {
40489
40489
  // If the status response is something telling that the transaction
@@ -41264,4 +41264,4 @@ exports.useWallet = useWallet;
41264
41264
  exports.useWallets = useWallets;
41265
41265
  exports.useXrplTrustLine = useXrplTrustLine;
41266
41266
  exports.walletSupportsChainType = walletSupportsChainType;
41267
- //# sourceMappingURL=index-CjYMwYuT.js.map
41267
+ //# sourceMappingURL=index-ClusSgCh.js.map