@0xsquid/react-hooks 8.3.1-beta-stellar-issued-assets.0 → 8.3.1-beta-update-ethers.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 (33) hide show
  1. package/dist/core/queries/queries-keys.d.ts +0 -4
  2. package/dist/core/types/index.d.ts +1 -1
  3. package/dist/core/types/stellar.d.ts +0 -26
  4. package/dist/core/types/tokens.d.ts +0 -4
  5. package/dist/hooks/index.d.ts +0 -1
  6. package/dist/{index-kjGUz03c.js → index-CMrdTYeW.js} +20 -232
  7. package/dist/index-CMrdTYeW.js.map +1 -0
  8. package/dist/{index-BXgsQg3P.js → index-qAOvcSon.js} +18 -236
  9. package/dist/index-qAOvcSon.js.map +1 -0
  10. package/dist/{index.es-GXiTUtqs.js → index.es-Cu_QQTg-.js} +2 -2
  11. package/dist/{index.es-GXiTUtqs.js.map → index.es-Cu_QQTg-.js.map} +1 -1
  12. package/dist/{index.es-ZxzIbkdb.js → index.es-DRgOycmm.js} +2 -2
  13. package/dist/{index.es-ZxzIbkdb.js.map → index.es-DRgOycmm.js.map} +1 -1
  14. package/dist/index.esm.js +1 -1
  15. package/dist/index.js +1 -7
  16. package/dist/index.js.map +1 -1
  17. package/dist/{secretService-X5xnwohc.js → secretService-B3sc6ibT.js} +2 -2
  18. package/dist/{secretService-X5xnwohc.js.map → secretService-B3sc6ibT.js.map} +1 -1
  19. package/dist/{secretService-BySTXkzG.js → secretService-B_-XWo1F.js} +2 -2
  20. package/dist/{secretService-BySTXkzG.js.map → secretService-B_-XWo1F.js.map} +1 -1
  21. package/dist/services/external/stellarApiClient.d.ts +0 -4
  22. package/dist/services/external/xrplRpcClient.d.ts +1 -2
  23. package/dist/services/index.d.ts +0 -1
  24. package/dist/services/internal/stellarService.d.ts +0 -2
  25. package/dist/services/internal/xrplService.d.ts +0 -2
  26. package/dist/{stellarService.client-hm8DCtO1.js → stellarService.client-Ciqw9lmL.js} +2 -2
  27. package/dist/{stellarService.client-hm8DCtO1.js.map → stellarService.client-Ciqw9lmL.js.map} +1 -1
  28. package/dist/{stellarService.client-T2DBSYr3.js → stellarService.client-sRzC5VSD.js} +2 -2
  29. package/dist/{stellarService.client-T2DBSYr3.js.map → stellarService.client-sRzC5VSD.js.map} +1 -1
  30. package/package.json +3 -3
  31. package/dist/hooks/stellar/useStellarTrustLine.d.ts +0 -13
  32. package/dist/index-BXgsQg3P.js.map +0 -1
  33. package/dist/index-kjGUz03c.js.map +0 -1
@@ -20117,17 +20117,14 @@ function isXrplAddressValid(address) {
20117
20117
  return rippleAddressCodec.isValidXAddress(address) || rippleAddressCodec.isValidClassicAddress(address);
20118
20118
  }
20119
20119
  function buildXrplTrustSetTx({ amount, sourceAddress, token, }) {
20120
- const asset = parseXrplTokenAddress(token.address);
20121
- if (!asset) {
20122
- throw new Error("Invalid asset");
20123
- }
20120
+ const [currency, issuer] = token.address.split(".");
20124
20121
  return {
20125
20122
  TransactionType: XrplTransactionType.TRUST_SET,
20126
20123
  Flags: XrplTransactionFlag.tfSetNoRipple,
20127
20124
  Account: sourceAddress,
20128
20125
  LimitAmount: {
20129
- currency: asset.code,
20130
- issuer: asset.issuer,
20126
+ currency,
20127
+ issuer,
20131
20128
  value: amount,
20132
20129
  },
20133
20130
  };
@@ -20156,16 +20153,6 @@ function parseXrplPaymentTx(data) {
20156
20153
  throw new Error("Could not parse payment transaction");
20157
20154
  }
20158
20155
  }
20159
- function parseXrplTokenAddress(address) {
20160
- const [code, issuer] = address.split(".");
20161
- if (!code || !issuer) {
20162
- return null;
20163
- }
20164
- return {
20165
- code,
20166
- issuer,
20167
- };
20168
- }
20169
20156
 
20170
20157
  const chains = [XrplCAIP2ChainId.MAINNET, XrplCAIP2ChainId.TESTNET];
20171
20158
  class XrplWalletConnect {
@@ -21152,16 +21139,6 @@ function stellarAddressToScVal(addressString) {
21152
21139
  type: "address",
21153
21140
  });
21154
21141
  }
21155
- function parseStellarAssetId(assetId) {
21156
- const [code, issuer] = assetId.split("-");
21157
- if (!code || !issuer) {
21158
- return null;
21159
- }
21160
- return {
21161
- code,
21162
- issuer,
21163
- };
21164
- }
21165
21142
 
21166
21143
  const SUI_FEATURES = ["sui:signTransaction"];
21167
21144
  function isSuiStandardWallet(wallet) {
@@ -22240,8 +22217,6 @@ exports.QueryKeys = void 0;
22240
22217
  QueryKeys["XrplAccountActivatedInfo"] = "xrplAccountActivatedInfo";
22241
22218
  QueryKeys["FiatToCryptoPaymentMethods"] = "fiatToCryptoPaymentMethods";
22242
22219
  QueryKeys["Stellar"] = "stellar";
22243
- QueryKeys["StellarTrustLine"] = "stellarTrustLine";
22244
- QueryKeys["IsStellarTrustLineApproved"] = "isStellarTrustLineApproved";
22245
22220
  QueryKeys["StellarAccountActivatedInfo"] = "stellarAccountActivatedInfo";
22246
22221
  QueryKeys["Hedera"] = "hedera";
22247
22222
  QueryKeys["IsHederaTokenAssociated"] = "isHederaTokenAssociated";
@@ -22429,23 +22404,6 @@ const keys = () => ({
22429
22404
  // ============
22430
22405
  // Stellar
22431
22406
  // ============
22432
- stellarTrustLine: (tokenAddress, chainId, address) => [
22433
- ...keys().stellar(),
22434
- exports.QueryKeys.StellarTrustLine,
22435
- tokenAddress,
22436
- chainId,
22437
- address,
22438
- ],
22439
- isStellarTrustLineApproved: (address, chainId, chainType, tokenAddress, trustLineLimit, amountToApprove) => [
22440
- ...keys().stellar(),
22441
- exports.QueryKeys.IsStellarTrustLineApproved,
22442
- address,
22443
- chainId,
22444
- chainType,
22445
- tokenAddress,
22446
- trustLineLimit,
22447
- amountToApprove?.toString(),
22448
- ],
22449
22407
  stellarAccountActivatedInfo: (address, chainId, chainType) => [
22450
22408
  ...keys().stellar(),
22451
22409
  exports.QueryKeys.StellarAccountActivatedInfo,
@@ -23195,7 +23153,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23195
23153
  };
23196
23154
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23197
23155
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23198
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BySTXkzG.js'); });
23156
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-B_-XWo1F.js'); });
23199
23157
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23200
23158
  };
23201
23159
  function getTokenAssetsKey(token) {
@@ -26480,7 +26438,7 @@ function useStellarWallets() {
26480
26438
  try {
26481
26439
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
26482
26440
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
26483
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-T2DBSYr3.js'); });
26441
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-sRzC5VSD.js'); });
26484
26442
  const modules = [...initializeAllModules(), new LedgerModule()];
26485
26443
  const promises = modules.map(async (module) => {
26486
26444
  const isAvailable = await module.isAvailable();
@@ -27980,7 +27938,7 @@ function hederaWalletConnect(parameters) {
27980
27938
  const optionalChains = config.chains.map((x) => x.id);
27981
27939
  if (!optionalChains.length)
27982
27940
  return;
27983
- const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-GXiTUtqs.js'); });
27941
+ const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-Cu_QQTg-.js'); });
27984
27942
  const rawProvider = await EthereumProvider.init({
27985
27943
  ...restParameters,
27986
27944
  disableProviderPing: true,
@@ -29519,9 +29477,9 @@ class XrplRpcClient {
29519
29477
  },
29520
29478
  ]);
29521
29479
  }
29522
- async getTrustLine(address, asset) {
29523
- const response = await this.getTrustLines(address, asset.issuer);
29524
- const trustLine = response.lines.find((line) => line.currency === asset.code);
29480
+ async getTrustLine(address, issuer, currency) {
29481
+ const response = await this.getTrustLines(address, issuer);
29482
+ const trustLine = response.lines.find((line) => line.currency === currency);
29525
29483
  return trustLine ?? null;
29526
29484
  }
29527
29485
  async accountActivatedInfo(address) {
@@ -29679,22 +29637,6 @@ async function createClient(chain) {
29679
29637
  }
29680
29638
  }
29681
29639
 
29682
- var StellarAssetType;
29683
- (function (StellarAssetType) {
29684
- /**
29685
- * XLM native token
29686
- */
29687
- StellarAssetType["NATIVE"] = "native";
29688
- /**
29689
- * 1-4 char asset code (e.g. USDC)
29690
- */
29691
- StellarAssetType["ALPHANUM4"] = "alphanum4";
29692
- /**
29693
- * 5-12 char asset code (e.g. wstETH)
29694
- */
29695
- StellarAssetType["ALPHANUM12"] = "alphanum12";
29696
- })(StellarAssetType || (StellarAssetType = {}));
29697
-
29698
29640
  class StellarApiClient {
29699
29641
  apiUrl;
29700
29642
  constructor(apiUrl) {
@@ -29713,26 +29655,9 @@ class StellarApiClient {
29713
29655
  const baseReserveBn = BigInt(latestLedger.base_reserve_in_stroops);
29714
29656
  return baseReserveBn;
29715
29657
  }
29716
- async getTrustLines(userAddress) {
29717
- const response = await fetch(`${this.apiUrl}/accounts/${userAddress}`);
29718
- if (!response.ok) {
29719
- throw new Error(`Failed to fetch account data: ${response.statusText}`);
29720
- }
29721
- const data = await response.json();
29722
- if (!Array.isArray(data?.balances)) {
29723
- throw new Error("Invalid response from Horizon API");
29724
- }
29725
- const assets = data.balances;
29726
- return assets.filter((asset) => asset.asset_type !== StellarAssetType.NATIVE);
29727
- }
29728
- async getTrustLine(address, asset) {
29729
- const trustLines = await this.getTrustLines(address);
29730
- const trustLine = trustLines.find((line) => line.asset_code === asset.code && line.asset_issuer === asset.issuer);
29731
- return trustLine ?? null;
29732
- }
29733
29658
  }
29734
29659
 
29735
- const DEFAULT_REFETCH_INTERVAL$2 = 20_000;
29660
+ const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
29736
29661
  function useStellarAccountActivation({ address, chain, token, }) {
29737
29662
  /**
29738
29663
  * Checks if the destination account exists on the Stellar network
@@ -29766,7 +29691,7 @@ function useStellarAccountActivation({ address, chain, token, }) {
29766
29691
  };
29767
29692
  },
29768
29693
  enabled: !!address && chain?.chainType === squidTypes.ChainType.STELLAR,
29769
- refetchInterval: DEFAULT_REFETCH_INTERVAL$2,
29694
+ refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
29770
29695
  refetchOnWindowFocus: true,
29771
29696
  });
29772
29697
  return {
@@ -29774,140 +29699,6 @@ function useStellarAccountActivation({ address, chain, token, }) {
29774
29699
  };
29775
29700
  }
29776
29701
 
29777
- /**
29778
- * Maximum asset amount on Stellar
29779
- * @see https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/assets#amount-precision
29780
- */
29781
- const MAX_ASSET_AMOUNT = "922337203685.4775807";
29782
- const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
29783
- function useStellarTrustLine({ address, chain, token, amount }) {
29784
- const { stellarSigner } = useSigner({ chain });
29785
- const queryClient = reactQuery.useQueryClient();
29786
- /**
29787
- * Retrieves the destination account's trust line data for the given token
29788
- */
29789
- const trustLineQuery = reactQuery.useQuery({
29790
- queryKey: keys().stellarTrustLine(token?.address, chain?.chainId, address),
29791
- queryFn: async () => {
29792
- if (chain?.chainType !== squidTypes.ChainType.STELLAR ||
29793
- token?.type !== squidTypes.ChainType.STELLAR) {
29794
- return null;
29795
- }
29796
- if (!address || !isStellarAddressValid(address)) {
29797
- return null;
29798
- }
29799
- const asset = parseStellarAssetId(token?.assetId);
29800
- if (!asset) {
29801
- return null;
29802
- }
29803
- // TODO: update types
29804
- const [horizonApiUrl] = chain?.horizonRpcList;
29805
- if (typeof horizonApiUrl !== "string") {
29806
- throw new Error("Invalid Horizon API URL");
29807
- }
29808
- const stellarApiClient = new StellarApiClient(horizonApiUrl);
29809
- const trustLine = await stellarApiClient.getTrustLine(address, asset);
29810
- return trustLine;
29811
- },
29812
- enabled: !!address &&
29813
- chain?.chainType === squidTypes.ChainType.STELLAR &&
29814
- token?.type === squidTypes.ChainType.STELLAR,
29815
- refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
29816
- });
29817
- /**
29818
- * Creates a trust line where the destination account authorizes to receive the given token
29819
- */
29820
- const createTrustLine = reactQuery.useMutation({
29821
- mutationFn: async () => {
29822
- try {
29823
- if (!stellarSigner) {
29824
- throw new Error("Stellar signer not found");
29825
- }
29826
- if (!address) {
29827
- throw new Error("Destination address is required");
29828
- }
29829
- if (chain?.chainType !== squidTypes.ChainType.STELLAR ||
29830
- token?.type !== squidTypes.ChainType.STELLAR) {
29831
- throw new Error("Chain and token to approve must be a Stellar token");
29832
- }
29833
- const assetInfo = parseStellarAssetId(token?.assetId);
29834
- if (!assetInfo) {
29835
- throw new Error("Invalid asset");
29836
- }
29837
- const network = getStellarNetwork(chain.chainId);
29838
- if (network == null) {
29839
- throw new Error(`Stellar network not found for chain ${chain.chainId}`);
29840
- }
29841
- const client = await getClient(chain);
29842
- const account = await client.getAccount(address);
29843
- const asset = new stellarSdk.Asset(assetInfo.code, assetInfo.issuer);
29844
- const changeTrustOperation = stellarSdk.Operation.changeTrust({
29845
- asset,
29846
- limit: MAX_ASSET_AMOUNT,
29847
- });
29848
- const builtTransaction = new stellarSdk.TransactionBuilder(account, {
29849
- fee: (BigInt(stellarSdk.BASE_FEE) * BigInt(2)).toString(),
29850
- networkPassphrase: network,
29851
- })
29852
- .addOperation(changeTrustOperation)
29853
- .setTimeout(300)
29854
- .build();
29855
- const { signedTxXdr } = await stellarSigner.signTransaction(builtTransaction.toXDR(), {
29856
- networkPassphrase: network,
29857
- });
29858
- const signedTransaction = new stellarSdk.Transaction(signedTxXdr, network);
29859
- const sentTransaction = await client.sendTransaction(signedTransaction);
29860
- const txStatus = await client.waitForTransaction(sentTransaction.hash, {
29861
- interval: 1_000,
29862
- });
29863
- if (txStatus !== stellarSdk.rpc.Api.GetTransactionStatus.SUCCESS) {
29864
- throw new Error(`Transaction failed with status: ${txStatus}`);
29865
- }
29866
- return true;
29867
- }
29868
- catch (error) {
29869
- console.error("Error creating trust line:", error);
29870
- return false;
29871
- }
29872
- },
29873
- async onSuccess() {
29874
- queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.StellarTrustLine));
29875
- },
29876
- });
29877
- /**
29878
- * Checks if the destination account has created a trust line to receive the given token.
29879
- */
29880
- const isTrustLineApproved = reactQuery.useQuery({
29881
- queryKey: keys().isStellarTrustLineApproved(address, token?.chainId, token?.type, token?.address, trustLineQuery.data?.limit, amount),
29882
- queryFn: async () => {
29883
- if (token?.type !== squidTypes.ChainType.STELLAR) {
29884
- return true;
29885
- }
29886
- // The native Stellar token doesn't need a trust line
29887
- if (token.address.toLowerCase() === nativeStellarTokenAddress.toLowerCase()) {
29888
- return true;
29889
- }
29890
- if (!amount) {
29891
- throw new Error("Amount is required");
29892
- }
29893
- const limitBn = BigNumber(trustLineQuery.data?.limit || "0");
29894
- const balanceBn = BigNumber(trustLineQuery.data?.balance || "0");
29895
- const availableAllowanceBn = limitBn.minus(balanceBn);
29896
- const amountBn = BigNumber(formatBNToReadable(amount, token.decimals));
29897
- return availableAllowanceBn.gte(amountBn);
29898
- },
29899
- enabled: !!address &&
29900
- !!amount &&
29901
- trustLineQuery?.isSuccess &&
29902
- token?.type === squidTypes.ChainType.STELLAR,
29903
- });
29904
- return {
29905
- createTrustLine,
29906
- trustLineQuery,
29907
- isTrustLineApproved,
29908
- };
29909
- }
29910
-
29911
29702
  const useAddressBookStore = zustand.create(middleware.persist((set) => ({
29912
29703
  addressBook: [],
29913
29704
  add: (newAddressData) => {
@@ -31530,18 +31321,15 @@ async function sendTransactionXrpl({ amount, signer, to, token, from, }) {
31530
31321
  txHash: hash,
31531
31322
  };
31532
31323
  }
31533
- const asset = parseXrplTokenAddress(token.address);
31534
- if (!asset) {
31535
- throw new Error("Invalid asset");
31536
- }
31324
+ const [currency, issuer] = token.address.split(".");
31537
31325
  const amountFormatted = formatBNToReadable(amount, token.decimals);
31538
31326
  const { hash } = await signer.signAndSubmit({
31539
31327
  network: xrplNetwork,
31540
31328
  tx: {
31541
31329
  ...baseTransaction,
31542
31330
  Amount: {
31543
- currency: asset.code,
31544
- issuer: asset.issuer,
31331
+ currency,
31332
+ issuer,
31545
31333
  value: amountFormatted,
31546
31334
  },
31547
31335
  },
@@ -36782,12 +36570,12 @@ function useXrplTrustLine({ address, chain, token, amount }) {
36782
36570
  if (!address || !isXrplAddressValid(address)) {
36783
36571
  return null;
36784
36572
  }
36785
- const trustLineAsset = parseXrplTokenAddress(token.address);
36786
- if (!trustLineAsset) {
36573
+ const [currency, issuer] = token.address.split(".");
36574
+ if (!currency || !issuer) {
36787
36575
  return null;
36788
36576
  }
36789
36577
  const xrplClient = await getClient(chain);
36790
- const trustLine = await xrplClient.getTrustLine(address, trustLineAsset);
36578
+ const trustLine = await xrplClient.getTrustLine(address, issuer, currency);
36791
36579
  return trustLine;
36792
36580
  },
36793
36581
  enabled: !!address &&
@@ -37113,7 +36901,6 @@ exports.getSecretNetworkBalances = getSecretNetworkBalances;
37113
36901
  exports.getSendTxStatusRefetchInterval = getSendTxStatusRefetchInterval;
37114
36902
  exports.getSourceExplorerTxUrl = getSourceExplorerTxUrl;
37115
36903
  exports.getStatusCode = getStatusCode;
37116
- exports.getStellarNetwork = getStellarNetwork;
37117
36904
  exports.getStepStatuses = getStepStatuses;
37118
36905
  exports.getStepsInfos = getStepsInfos;
37119
36906
  exports.getSuggestedAmountsForCurrency = getSuggestedAmountsForCurrency;
@@ -37149,7 +36936,6 @@ exports.isHistoryTransactionWarning = isHistoryTransactionWarning;
37149
36936
  exports.isProblematicConnector = isProblematicConnector;
37150
36937
  exports.isSolanaAddressValid = isSolanaAddressValid;
37151
36938
  exports.isStatusError = isStatusError;
37152
- exports.isStellarAddressValid = isStellarAddressValid;
37153
36939
  exports.isSwapRouteError = isSwapRouteError;
37154
36940
  exports.isUserRejectionError = isUserRejectionError;
37155
36941
  exports.isWalletAddressValid = isWalletAddressValid;
@@ -37168,10 +36954,8 @@ exports.normalizeError = normalizeError;
37168
36954
  exports.normalizeIbcAddress = normalizeIbcAddress;
37169
36955
  exports.normalizeTokenSymbol = normalizeTokenSymbol;
37170
36956
  exports.parseEvmAddress = parseEvmAddress;
37171
- exports.parseStellarAssetId = parseStellarAssetId;
37172
36957
  exports.parseToBigInt = parseToBigInt;
37173
36958
  exports.parseXrplPaymentTx = parseXrplPaymentTx;
37174
- exports.parseXrplTokenAddress = parseXrplTokenAddress;
37175
36959
  exports.populateWallets = populateWallets;
37176
36960
  exports.randomIntFromInterval = randomIntFromInterval;
37177
36961
  exports.redirectToExtensionsStore = redirectToExtensionsStore;
@@ -37184,7 +36968,6 @@ exports.sortAddressBook = sortAddressBook;
37184
36968
  exports.sortAllTokens = sortAllTokens;
37185
36969
  exports.sortTokensBySharedSubgraphIds = sortTokensBySharedSubgraphIds;
37186
36970
  exports.sortWallets = sortWallets;
37187
- exports.stellarAddressToScVal = stellarAddressToScVal;
37188
36971
  exports.suggestChainOrThrow = suggestChainOrThrow;
37189
36972
  exports.transactionErrorCode = transactionErrorCode;
37190
36973
  exports.trimExtraDecimals = trimExtraDecimals;
@@ -37250,7 +37033,6 @@ exports.useSquidQueryClient = useSquidQueryClient;
37250
37033
  exports.useSquidStore = useSquidStore;
37251
37034
  exports.useSquidTokens = useSquidTokens;
37252
37035
  exports.useStellarAccountActivation = useStellarAccountActivation;
37253
- exports.useStellarTrustLine = useStellarTrustLine;
37254
37036
  exports.useSuggestedFiatAmounts = useSuggestedFiatAmounts;
37255
37037
  exports.useSwap = useSwap;
37256
37038
  exports.useSwapRoutePersistStore = useSwapRoutePersistStore;
@@ -37266,4 +37048,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
37266
37048
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
37267
37049
  exports.walletIconBaseUrl = walletIconBaseUrl;
37268
37050
  exports.walletSupportsChainType = walletSupportsChainType;
37269
- //# sourceMappingURL=index-BXgsQg3P.js.map
37051
+ //# sourceMappingURL=index-qAOvcSon.js.map