@0xsquid/react-hooks 8.10.0 → 8.10.1-beta-bitcoin-coralv2.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 (25) hide show
  1. package/dist/core/connectors/bitcoin/wallets/keplr.d.ts +3 -0
  2. package/dist/core/connectors/bitcoin/wallets/phantom.d.ts +3 -1
  3. package/dist/core/connectors/bitcoin/wallets/unisat.d.ts +15 -0
  4. package/dist/core/types/bitcoin.d.ts +3 -0
  5. package/dist/{index-Dzir2lUQ.js → index-Cw1rn5LQ.js} +124 -46
  6. package/dist/index-Cw1rn5LQ.js.map +1 -0
  7. package/dist/{index-BlB3yIoX.js → index-Dykfm_Bt.js} +124 -46
  8. package/dist/index-Dykfm_Bt.js.map +1 -0
  9. package/dist/{index.es-BPXYaraD.js → index.es-DQyW9YL5.js} +2 -2
  10. package/dist/{index.es-BPXYaraD.js.map → index.es-DQyW9YL5.js.map} +1 -1
  11. package/dist/{index.es-DwtZr7bN.js → index.es-DspxF1i7.js} +2 -2
  12. package/dist/{index.es-DwtZr7bN.js.map → index.es-DspxF1i7.js.map} +1 -1
  13. package/dist/index.esm.js +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/{secretService-ICina23f.js → secretService-6H3XQVCV.js} +2 -2
  16. package/dist/{secretService-ICina23f.js.map → secretService-6H3XQVCV.js.map} +1 -1
  17. package/dist/{secretService-eiBnD7dI.js → secretService-C_gWAduF.js} +2 -2
  18. package/dist/{secretService-eiBnD7dI.js.map → secretService-C_gWAduF.js.map} +1 -1
  19. package/dist/{stellarService.client-VOmCOPzL.js → stellarService.client-BdMbbog4.js} +2 -2
  20. package/dist/{stellarService.client-VOmCOPzL.js.map → stellarService.client-BdMbbog4.js.map} +1 -1
  21. package/dist/{stellarService.client-Bjc92sC_.js → stellarService.client-CElL9N4g.js} +2 -2
  22. package/dist/{stellarService.client-Bjc92sC_.js.map → stellarService.client-CElL9N4g.js.map} +1 -1
  23. package/package.json +1 -1
  24. package/dist/index-BlB3yIoX.js.map +0 -1
  25. package/dist/index-Dzir2lUQ.js.map +0 -1
@@ -4743,6 +4743,25 @@ class KeplrConnector {
4743
4743
  address: account,
4744
4744
  };
4745
4745
  }
4746
+ async signPsbt(psbtHex) {
4747
+ // Keplr follows the UniSat-style Bitcoin provider API: `signPsbt` signs and,
4748
+ // with `autoFinalized` (the default), finalizes every input, returning the
4749
+ // signed PSBT as a hex string.
4750
+ // https://docs.keplr.app/api/bitcoin
4751
+ const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
4752
+ autoFinalized: true,
4753
+ });
4754
+ // Keplr only exposes `pushTx`, so extract the finalized raw transaction from
4755
+ // the signed PSBT before broadcasting it.
4756
+ const rawTxHex = bitcoin.Psbt.fromHex(signedPsbtHex)
4757
+ .extractTransaction()
4758
+ .toHex();
4759
+ const txHash = await this.getProvider.pushTx(rawTxHex);
4760
+ if (!txHash) {
4761
+ throw new BitcoinConnectorTransactionFailedError();
4762
+ }
4763
+ return { txHash };
4764
+ }
4746
4765
  }
4747
4766
 
4748
4767
  bitcoin.initEccLib(ecc);
@@ -4857,10 +4876,8 @@ class PhantomConnector {
4857
4876
  async sendBTC(to, amount) {
4858
4877
  const { address } = await this.requestAccount();
4859
4878
  const { psbtHex } = await createSendBtcPsbt(address, to, amount);
4860
- const { txId } = await this.signPsbt(psbtHex);
4861
- if (!txId)
4862
- throw new BitcoinConnectorTransactionFailedError();
4863
- return { txHash: txId };
4879
+ const { txHash } = await this.signPsbt(psbtHex);
4880
+ return { txHash };
4864
4881
  }
4865
4882
  async signPsbt(psbtHex) {
4866
4883
  const { address: paymentAddress } = await this.requestAccount();
@@ -4881,8 +4898,10 @@ class PhantomConnector {
4881
4898
  const signedPsbt = bitcoin.Psbt.fromBuffer(signedPsbtBytes);
4882
4899
  signedPsbt.finalizeAllInputs();
4883
4900
  const tx = signedPsbt.extractTransaction();
4884
- const txId = await broadcastTx(tx.toHex());
4885
- return { txId };
4901
+ const txHash = await broadcastTx(tx.toHex());
4902
+ if (!txHash)
4903
+ throw new BitcoinConnectorTransactionFailedError();
4904
+ return { txHash };
4886
4905
  }
4887
4906
  }
4888
4907
 
@@ -4911,6 +4930,21 @@ class UnisatConnector {
4911
4930
  address: account,
4912
4931
  };
4913
4932
  }
4933
+ async signPsbt(psbtHex) {
4934
+ // UniSat signs and, with `autoFinalized` (the default), finalizes every
4935
+ // input, returning the signed PSBT as a hex string.
4936
+ // https://docs.unisat.io/dev/unisat-developer-center/unisat-wallet/api-list
4937
+ const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
4938
+ autoFinalized: true,
4939
+ });
4940
+ // `pushPsbt` extracts the finalized transaction from the signed PSBT and
4941
+ // broadcasts it, returning the transaction id.
4942
+ const txHash = await this.getProvider.pushPsbt(signedPsbtHex);
4943
+ if (!txHash) {
4944
+ throw new BitcoinConnectorTransactionFailedError();
4945
+ }
4946
+ return { txHash };
4947
+ }
4914
4948
  }
4915
4949
 
4916
4950
  var XrplTransactionType;
@@ -23584,7 +23618,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23584
23618
  };
23585
23619
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23586
23620
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23587
- const { fetchAllSecretBalances } = await import('./secretService-eiBnD7dI.js');
23621
+ const { fetchAllSecretBalances } = await import('./secretService-C_gWAduF.js');
23588
23622
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23589
23623
  };
23590
23624
  function getTokenAssetsKey(token) {
@@ -27258,7 +27292,7 @@ function useStellarWallets() {
27258
27292
  try {
27259
27293
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
27260
27294
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
27261
- const { formatStellarWallet } = await import('./stellarService.client-VOmCOPzL.js');
27295
+ const { formatStellarWallet } = await import('./stellarService.client-BdMbbog4.js');
27262
27296
  const modules = [...initializeAllModules(), new LedgerModule()];
27263
27297
  const promises = modules.map(async (module) => {
27264
27298
  const isAvailable = await module.isAvailable();
@@ -30717,7 +30751,7 @@ function hederaWalletConnect(parameters) {
30717
30751
  const optionalChains = config.chains.map((x) => x.id);
30718
30752
  if (!optionalChains.length)
30719
30753
  return;
30720
- const { EthereumProvider } = await import('./index.es-DwtZr7bN.js');
30754
+ const { EthereumProvider } = await import('./index.es-DspxF1i7.js');
30721
30755
  const rawProvider = await EthereumProvider.init({
30722
30756
  ...restParameters,
30723
30757
  disableProviderPing: true,
@@ -37444,47 +37478,91 @@ const useExecuteTransaction = (squidRoute) => {
37444
37478
  }
37445
37479
  });
37446
37480
  const swapMutationBitcoin = useMutation(async ({ id, route }) => {
37447
- const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
37448
- if (!depositAddress) {
37449
- throw new Error(`Invalid deposit address: ${depositAddress}`);
37450
- }
37451
- if (!sendAmount) {
37452
- throw new Error(`Invalid send amount: ${sendAmount}`);
37481
+ console.log("Validating route", {
37482
+ bitcoinSigner,
37483
+ route,
37484
+ });
37485
+ if (!bitcoinSigner || !route?.transactionRequest) {
37486
+ throw new Error("Need all parameters");
37453
37487
  }
37454
- const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
37455
- await changeNetworkIfNeeded.mutateAsync();
37456
- if (allParamsValid) {
37457
- dispatchSignatureRequestEvent(route);
37458
- const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
37459
- if (txHash) {
37460
- resetQueriesAfterTxSigned();
37488
+ switch (route.transactionRequest.type) {
37489
+ case SquidDataType.ChainflipDepositAddress: {
37490
+ const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
37491
+ const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
37492
+ if (!allParamsValid) {
37493
+ throw new Error("Need all parameters");
37494
+ }
37495
+ await changeNetworkIfNeeded.mutateAsync();
37496
+ dispatchSignatureRequestEvent(route);
37497
+ const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
37498
+ if (txHash) {
37499
+ resetQueriesAfterTxSigned();
37500
+ }
37501
+ // Dispatch event so it can be listened from outside the widget
37502
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
37503
+ if (route.transactionRequest) {
37504
+ const txParams = setTransactionState({
37505
+ route,
37506
+ txHash,
37507
+ // When bridging from Bitcoin we need to send the chainflipId to the status endpoint
37508
+ // instead of the Bitcoin transaction hash
37509
+ transactionIdForStatus: statusTrackingId,
37510
+ userAddress: sourceUserAddress,
37511
+ status: TransactionStatus.INITIAL_LOADING,
37512
+ sourceStatus: TransactionStatus.ONGOING,
37513
+ axelarUrl: undefined,
37514
+ id,
37515
+ });
37516
+ if (txParams) {
37517
+ addSwapTransaction({
37518
+ ...txParams,
37519
+ params: route.params,
37520
+ estimate: route.estimate,
37521
+ });
37522
+ }
37523
+ }
37524
+ break;
37461
37525
  }
37462
- // Dispatch event so it can be listened from outside the widget
37463
- WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
37464
- if (route.transactionRequest) {
37465
- const txParams = setTransactionState({
37466
- route,
37467
- txHash,
37468
- // When bridging from Bitcoin we need to send the chainflipId to the status endpoint
37469
- // instead of the Bitcoin transaction hash
37470
- transactionIdForStatus: statusTrackingId,
37471
- userAddress: sourceUserAddress,
37472
- status: TransactionStatus.INITIAL_LOADING,
37473
- sourceStatus: TransactionStatus.ONGOING,
37474
- axelarUrl: undefined,
37475
- id,
37476
- });
37477
- if (txParams) {
37478
- addSwapTransaction({
37479
- ...txParams,
37480
- params: route.params,
37481
- estimate: route.estimate,
37526
+ case SquidDataType.DepositAddressCalldata: {
37527
+ console.log(`Route type: ${route.transactionRequest?.type}`);
37528
+ if (!isOnChainTxData(route.transactionRequest)) {
37529
+ console.log("Invalid route data", route.transactionRequest);
37530
+ throw new Error("Invalid route data");
37531
+ }
37532
+ const { data: transactionHex } = route.transactionRequest;
37533
+ await changeNetworkIfNeeded.mutateAsync();
37534
+ dispatchSignatureRequestEvent(route);
37535
+ console.log("Signing psbt", { transactionHex });
37536
+ const { txHash } = await bitcoinSigner.signPsbt(transactionHex);
37537
+ console.log("Signed psbt", { txHash });
37538
+ if (txHash) {
37539
+ resetQueriesAfterTxSigned();
37540
+ }
37541
+ // Dispatch event so it can be listened from outside the widget
37542
+ WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
37543
+ if (route.transactionRequest) {
37544
+ const txParams = setTransactionState({
37545
+ route,
37546
+ txHash,
37547
+ userAddress: sourceUserAddress,
37548
+ status: TransactionStatus.INITIAL_LOADING,
37549
+ sourceStatus: TransactionStatus.ONGOING,
37550
+ axelarUrl: undefined,
37551
+ id,
37482
37552
  });
37553
+ if (txParams) {
37554
+ addSwapTransaction({
37555
+ ...txParams,
37556
+ params: route.params,
37557
+ estimate: route.estimate,
37558
+ });
37559
+ }
37483
37560
  }
37561
+ break;
37562
+ }
37563
+ default: {
37564
+ throw new Error(`Unhandled route type ${route.transactionRequest.type}`);
37484
37565
  }
37485
- }
37486
- else {
37487
- throw new Error("Need all parameters");
37488
37566
  }
37489
37567
  });
37490
37568
  const swapMutationXrpl = useMutation(async ({ id, route }) => {
@@ -38645,4 +38723,4 @@ const SquidProvider = ({ children, config, placeholder, }) => {
38645
38723
  };
38646
38724
 
38647
38725
  export { useDepositAddress as $, AxelarStatusResponseType as A, useHederaTokenAssociations as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useKeyboardNavigation as E, useSquidQueryClient as F, useSquid as G, HistoryTxType as H, useStellarAccountActivation as I, useStellarTrustLine as J, useAddressBookStore as K, useAssetsColorsStore as L, useFavoriteTokensStore as M, Nr as N, useHistoryStore as O, useSendTransactionStore as P, QueryKeys as Q, useConfigStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSquidStore as U, useSwapRoutePersistStore as V, Wo as W, XamanXrplNetwork as X, useTransactionStore as Y, ConnectingWalletStatus as Z, useWalletStore as _, WindowWalletFlag as a, useRecommendedQuote as a$, useSwap as a0, buildUrlSearchParamsFromSwapEvent as a1, parseInitialAssetsFromUrl as a2, useUrlSwapParams as a3, useAllConnectedWalletBalances as a4, useAllTokensWithBalanceForChainType as a5, useCosmosBalance as a6, useEvmBalance as a7, useMultiChainBalance as a8, useMultipleTokenPrices as a9, useSendTransactionStatus as aA, useSwapTransactionStatus as aB, useAvatar as aC, useHistory as aD, useDebouncedValue as aE, useAddToken as aF, useAutoConnect as aG, useEnsDataForAddress as aH, useEnsSearch as aI, useGnosisContext as aJ, useIsSameAddressAndGnosisContext as aK, useIntegratorContext as aL, useMultiChainWallet as aM, useSigner as aN, useWallet as aO, useWallets as aP, useXrplTrustLine as aQ, TX_STATUS_CONSTANTS as aR, FINAL_TRANSACTION_STATUSES as aS, useGetFiatQuote as aT, useGetOnRampConfig as aU, useExecuteFiatQuote as aV, useFiatOnRampTxStatus as aW, useFiatTransactions as aX, useCurrencyDetails as aY, useCountryDetails as aZ, useAvailableQuotes as a_, useBitcoinNativeBalance as aa, useCosmosNativeBalance as ab, useEvmNativeBalance as ac, useNativeBalance as ad, useSolanaNativeBalance as ae, useStellarNativeBalance as af, useSuiNativeBalance as ag, useXrplNativeBalance as ah, useNativeTokenForChain as ai, useSingleTokenPrice as aj, useSourceChainGasToken as ak, useSquidTokens as al, useHistoricalData as am, useTokensData as an, useEstimateSendTransaction as ao, useSendTransaction as ap, useSendTransactionGas as aq, useAllTransactionsStatus as ar, useApproval as as, useDepositTransactionStatus as at, useEstimate as au, useEstimatePriceImpact as av, useExecuteTransaction as aw, useGetRoute as ax, useGetRouteWrapper as ay, useRouteWarnings as az, chainTypeToZeroAddressMap as b, parseEvmAddress as b$, useGetOnrampPaymentTypes as b0, useSuggestedFiatAmounts as b1, SquidProvider as b2, EnsService as b3, getXummClient as b4, isXamanXAppContext as b5, getQueryHeaders as b6, getStatusCode as b7, is404Error as b8, assetsBaseUrl as b9, getTokensForChain as bA, getFirstAvailableChainId as bB, fetchHighestBalanceToken as bC, getInitialOrDefaultTokenAddressForChain as bD, getInitialTokenAddressForChain as bE, filterTokensForDestination as bF, getInitialChainIdFromConfig as bG, getCosmosKey as bH, getKeysSettled as bI, getAllKeysForSupportedCosmosChains as bJ, isCosmosAddressValid as bK, getCosmosSigningClient as bL, getCosmosChainInfosObject as bM, connectCosmosWallet as bN, isFallbackAddressNeeded as bO, suggestChainOrThrow as bP, normalizeError as bQ, transactionErrorCode as bR, isUserRejectionError as bS, getTransactionError as bT, handleTransactionErrorEvents as bU, isSwapRouteError as bV, isStatusError as bW, createQuoteRequestParamsHash as bX, WidgetEvents as bY, EvmNetworkNotSupportedErrorCode as bZ, addEthereumChain as b_, shareSubgraphId as ba, sortTokensBySharedSubgraphIds as bb, getSupportedChainIdsForDirection as bc, filterChains as bd, filterTokens as be, getTokenImage as bf, getNewSwapParamsFromInput as bg, sortAllTokens as bh, findToken as bi, findNativeToken as bj, normalizeIbcAddress as bk, groupTokensBySymbol as bl, groupTokensByChainId as bm, filterViewableTokens as bn, getSecretNetworkBalances as bo, getTokenAssetsKey as bp, fetchAssetsColors as bq, isSupportedChainType as br, initializeSquidData as bs, isEmptyObject as bt, normalizeTokenSymbol as bu, areTokenSymbolsCompatible as bv, isEvmosChain as bw, resolveChainIdFromAsset as bx, getConfigWithDefaults as by, randomIntFromInterval as bz, chainTypeToNativeTokenAddressMap as c, getBridgeType as c$, formatEvmWallet as c0, filterWagmiConnector as c1, waitForReceiptWithRetry as c2, getUserCountry as c3, getCountryData as c4, getCurrencyData as c5, adaptiveRound as c6, getSuggestedAmountsForCurrency as c7, HederaExtensionHelper as c8, convertHederaAccountIdToEvmAddress as c9, getStellarHorizonApiUrl as cA, isValidIssuedAsset as cB, isValidHorizonAsset as cC, formatTransactionHistoryDate as cD, getAxelarExplorerTxUrl as cE, getSourceExplorerTxUrl as cF, getMainExplorerUrl as cG, formatDistance as cH, formatSeconds as cI, formatSwapTxStatusResponseForStorage as cJ, simplifyRouteAction as cK, fetchSwapTransactionStatus as cL, compareTransactionIds as cM, isCoralBridgeAction as cN, isActionCompletedOnSourceTx as cO, sleep as cP, isChainflipDepositRoute as cQ, isChainflipBridgeTransaction as cR, isOnChainTxData as cS, isDepositAddressDirectTransferRoute as cT, getHistoryTransactionId as cU, getStepStatuses as cV, getHalfSuccessState as cW, getStepsInfos as cX, getSwapTxStatusRefetchInterval as cY, getSendTxStatusRefetchInterval as cZ, chainflipMultihopBridgeType as c_, convertEvmAddressToHederaAccountId as ca, scaleHbarToWei as cb, scaleWeiToHbar as cc, parseToBigInt as cd, roundNumericValue as ce, formatUnitsRounded as cf, formatTokenAmount as cg, formatUsdAmount as ch, trimExtraDecimals as ci, getNumericValue as cj, cleanAmount as ck, convertTokenAmountToUSD as cl, convertUSDToTokenAmount as cm, calculateTotal24hChange as cn, getRouteExpiry as co, searchTokens as cp, filterSolanaWallets as cq, isSolanaAddressValid as cr, executeSolanaSwap as cs, executeSolanaTransfer as ct, isStellarAddressValid as cu, getStellarNetwork as cv, stellarAddressToScVal as cw, getStellarTrustLineAsset as cx, isStellarToken as cy, isStellarIssuedToken as cz, definedInWindow as d, getTransactionStatus as d0, getTransactionEndStatus as d1, isHistoryTransactionPending as d2, isHistoryTransactionFailed as d3, isHistoryTransactionWarning as d4, isHistoryTransactionEnded as d5, formatHash as d6, isWalletAddressValid as d7, redirectToExtensionsStore as d8, populateWallets as d9, buildFallbackWallets as da, getDefaultChain as db, sortWallets as dc, areSameAddress as dd, sortAddressBook as de, calculateTotalUsdBalanceUSD as df, addTokenToWallet as dg, isEvmChainNotSupportedError as dh, getWalletSupportedChainTypes as di, getConnectorForChainType as dj, walletSupportsChainType as dk, connectWallet as dl, cancelConnectWallet as dm, isProblematicConnector as dn, mergeWallets as dp, isXionSmartContractAddress as dq, isXrplAddressValid as dr, buildXrplTrustSetTx as ds, getXrplNetwork as dt, parseXrplPaymentTx as du, parseXrplTokenAddress as dv, er as e, formatBNToReadable as f, DEFAULT_ROUTE_REFETCH_INTERVAL as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCosmosTokenAddress as j, nativeEvmTokenAddress as k, nativeSolanaTokenAddress as l, nativeStellarTokenAddress as m, nativeBitcoinTokenAddress as n, nativeSuiTokenAddress as o, nativeXrplTokenAddress as p, CosmosProvider as q, SendTransactionStatus as r, TransactionStatus as s, useTrackSearchEmpty as t, useCosmosContext as u, useSquidChains as v, walletIconBaseUrl as w, useClient as x, useCosmosForChain as y, useHederaAccountActivation as z };
38648
- //# sourceMappingURL=index-BlB3yIoX.js.map
38726
+ //# sourceMappingURL=index-Dykfm_Bt.js.map