@0xsquid/react-hooks 8.3.1-beta-stellar-issued-assets.1 → 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 (35) hide show
  1. package/dist/core/queries/queries-keys.d.ts +1 -5
  2. package/dist/core/types/index.d.ts +1 -1
  3. package/dist/core/types/stellar.d.ts +0 -52
  4. package/dist/core/types/tokens.d.ts +0 -4
  5. package/dist/hooks/index.d.ts +0 -1
  6. package/dist/{index-DPakWLan.js → index-CMrdTYeW.js} +29 -324
  7. package/dist/index-CMrdTYeW.js.map +1 -0
  8. package/dist/{index-CJQHDfLM.js → index-qAOvcSon.js} +27 -333
  9. package/dist/index-qAOvcSon.js.map +1 -0
  10. package/dist/{index.es-CT2n71aB.js → index.es-Cu_QQTg-.js} +2 -2
  11. package/dist/{index.es-CT2n71aB.js.map → index.es-Cu_QQTg-.js.map} +1 -1
  12. package/dist/{index.es-CMuCSzqv.js → index.es-DRgOycmm.js} +2 -2
  13. package/dist/{index.es-CMuCSzqv.js.map → index.es-DRgOycmm.js.map} +1 -1
  14. package/dist/index.esm.js +1 -1
  15. package/dist/index.js +1 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/{secretService-D8hWz2Gz.js → secretService-B3sc6ibT.js} +2 -2
  18. package/dist/{secretService-D8hWz2Gz.js.map → secretService-B3sc6ibT.js.map} +1 -1
  19. package/dist/{secretService-CdbkGf17.js → secretService-B_-XWo1F.js} +2 -2
  20. package/dist/{secretService-CdbkGf17.js.map → secretService-B_-XWo1F.js.map} +1 -1
  21. package/dist/services/external/rpcService.d.ts +1 -1
  22. package/dist/services/external/stellarApiClient.d.ts +0 -4
  23. package/dist/services/external/stellarRpcClient.d.ts +2 -2
  24. package/dist/services/external/xrplRpcClient.d.ts +1 -2
  25. package/dist/services/index.d.ts +0 -1
  26. package/dist/services/internal/stellarService.d.ts +0 -9
  27. package/dist/services/internal/xrplService.d.ts +0 -2
  28. package/dist/{stellarService.client-Dve9IZZm.js → stellarService.client-Ciqw9lmL.js} +2 -2
  29. package/dist/{stellarService.client-Dve9IZZm.js.map → stellarService.client-Ciqw9lmL.js.map} +1 -1
  30. package/dist/{stellarService.client-ESo7_qhK.js → stellarService.client-sRzC5VSD.js} +2 -2
  31. package/dist/{stellarService.client-ESo7_qhK.js.map → stellarService.client-sRzC5VSD.js.map} +1 -1
  32. package/package.json +3 -3
  33. package/dist/hooks/stellar/useStellarTrustLine.d.ts +0 -13
  34. package/dist/index-CJQHDfLM.js.map +0 -1
  35. package/dist/index-DPakWLan.js.map +0 -1
@@ -13,7 +13,7 @@ import { isValidXAddress, isValidClassicAddress } from 'ripple-address-codec';
13
13
  import { getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createTransferInstruction } from '@solana/spl-token';
14
14
  import { StandardWalletAdapter } from '@solana/wallet-standard-wallet-adapter-base';
15
15
  import { PublicKey, VersionedTransaction, Transaction, SystemProgram, Connection } from '@solana/web3.js';
16
- import { StrKey, Networks, nativeToScVal, Address, rpc, TransactionBuilder, BASE_FEE, Contract, TimeoutInfinite, scValToNative, Asset, Operation, Transaction as Transaction$1, xdr } from '@stellar/stellar-sdk';
16
+ import { Networks, StrKey, nativeToScVal, Address, rpc, TransactionBuilder, BASE_FEE, Contract, TimeoutInfinite, scValToNative, Operation, Transaction as Transaction$1, xdr } from '@stellar/stellar-sdk';
17
17
  import { SUI_TESTNET_CHAIN, SUI_MAINNET_CHAIN } from '@mysten/wallet-standard';
18
18
  import { CloudflareProvider, BrowserProvider, JsonRpcSigner, JsonRpcProvider, ethers, Interface, Contract as Contract$1, isError } from 'ethers';
19
19
  import BigNumber$1, { BigNumber } from 'bignumber.js';
@@ -20096,17 +20096,14 @@ function isXrplAddressValid(address) {
20096
20096
  return isValidXAddress(address) || isValidClassicAddress(address);
20097
20097
  }
20098
20098
  function buildXrplTrustSetTx({ amount, sourceAddress, token, }) {
20099
- const asset = parseXrplTokenAddress(token.address);
20100
- if (!asset) {
20101
- throw new Error("Invalid asset");
20102
- }
20099
+ const [currency, issuer] = token.address.split(".");
20103
20100
  return {
20104
20101
  TransactionType: XrplTransactionType.TRUST_SET,
20105
20102
  Flags: XrplTransactionFlag.tfSetNoRipple,
20106
20103
  Account: sourceAddress,
20107
20104
  LimitAmount: {
20108
- currency: asset.code,
20109
- issuer: asset.issuer,
20105
+ currency,
20106
+ issuer,
20110
20107
  value: amount,
20111
20108
  },
20112
20109
  };
@@ -20135,16 +20132,6 @@ function parseXrplPaymentTx(data) {
20135
20132
  throw new Error("Could not parse payment transaction");
20136
20133
  }
20137
20134
  }
20138
- function parseXrplTokenAddress(address) {
20139
- const [code, issuer] = address.split(".");
20140
- if (!code || !issuer) {
20141
- return null;
20142
- }
20143
- return {
20144
- code,
20145
- issuer,
20146
- };
20147
- }
20148
20135
 
20149
20136
  const chains = [XrplCAIP2ChainId.MAINNET, XrplCAIP2ChainId.TESTNET];
20150
20137
  class XrplWalletConnect {
@@ -21110,28 +21097,6 @@ const executeSolanaTransfer = async ({ amount, target, signer, connection, sourc
21110
21097
  return signature;
21111
21098
  };
21112
21099
 
21113
- var StellarHorizonAssetType;
21114
- (function (StellarHorizonAssetType) {
21115
- /**
21116
- * XLM native token
21117
- */
21118
- StellarHorizonAssetType["NATIVE"] = "native";
21119
- /**
21120
- * 1-4 char asset code (e.g. USDC)
21121
- */
21122
- StellarHorizonAssetType["ALPHANUM4"] = "credit_alphanum4";
21123
- /**
21124
- * 5-12 char asset code (e.g. wstETH)
21125
- */
21126
- StellarHorizonAssetType["ALPHANUM12"] = "credit_alphanum12";
21127
- })(StellarHorizonAssetType || (StellarHorizonAssetType = {}));
21128
- var StellarTokenType;
21129
- (function (StellarTokenType) {
21130
- StellarTokenType["NATIVE_TOKEN"] = "nativeToken";
21131
- StellarTokenType["ISSUER_TOKEN"] = "issuerToken";
21132
- StellarTokenType["CONTRACT_TOKEN"] = "contractToken";
21133
- })(StellarTokenType || (StellarTokenType = {}));
21134
-
21135
21100
  function isStellarAddressValid(address) {
21136
21101
  return StrKey.isValidEd25519PublicKey(address);
21137
21102
  }
@@ -21153,78 +21118,6 @@ function stellarAddressToScVal(addressString) {
21153
21118
  type: "address",
21154
21119
  });
21155
21120
  }
21156
- function getStellarTrustLineAsset(token) {
21157
- // The address format for issued assets is `CODE-ISSUER`
21158
- // Example: USDC-GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN
21159
- const [code, issuer] = token.address.split("-");
21160
- if (!code || !issuer) {
21161
- return null;
21162
- }
21163
- return {
21164
- code,
21165
- issuer,
21166
- };
21167
- }
21168
- function isStellarToken(token) {
21169
- try {
21170
- const stellarToken = token;
21171
- return (Object.values(StellarTokenType).includes(stellarToken.chainAssetConfig.stellar.assetType) &&
21172
- typeof stellarToken.chainAssetConfig.stellar.contractAddress === "string");
21173
- }
21174
- catch {
21175
- return false;
21176
- }
21177
- }
21178
- function isStellarIssuedToken(token) {
21179
- try {
21180
- return (isStellarToken(token) &&
21181
- token.chainAssetConfig.stellar.assetType === StellarTokenType.ISSUER_TOKEN);
21182
- }
21183
- catch {
21184
- return false;
21185
- }
21186
- }
21187
- function getStellarHorizonApiUrl(chain) {
21188
- try {
21189
- const stellarChain = chain;
21190
- const [horizonApiUrl] = stellarChain.horizonRpcList;
21191
- if (typeof horizonApiUrl !== "string") {
21192
- throw new Error("Invalid Horizon API URL");
21193
- }
21194
- return horizonApiUrl;
21195
- }
21196
- catch {
21197
- return null;
21198
- }
21199
- }
21200
- const VALID_ASSET_TYPES = new Set(Object.values(StellarHorizonAssetType));
21201
- function isValidNativeAsset(asset) {
21202
- return (typeof asset === "object" &&
21203
- asset !== null &&
21204
- "balance" in asset &&
21205
- typeof asset.balance === "string" &&
21206
- "asset_type" in asset &&
21207
- asset.asset_type === StellarHorizonAssetType.NATIVE);
21208
- }
21209
- function isValidIssuedAsset(asset) {
21210
- return (typeof asset === "object" &&
21211
- asset !== null &&
21212
- "balance" in asset &&
21213
- typeof asset.balance === "string" &&
21214
- "asset_type" in asset &&
21215
- typeof asset.asset_type === "string" &&
21216
- VALID_ASSET_TYPES.has(asset.asset_type) &&
21217
- asset.asset_type !== StellarHorizonAssetType.NATIVE &&
21218
- "asset_code" in asset &&
21219
- typeof asset.asset_code === "string" &&
21220
- "asset_issuer" in asset &&
21221
- typeof asset.asset_issuer === "string" &&
21222
- "limit" in asset &&
21223
- typeof asset.limit === "string");
21224
- }
21225
- function isValidHorizonAsset(asset) {
21226
- return isValidNativeAsset(asset) || isValidIssuedAsset(asset);
21227
- }
21228
21121
 
21229
21122
  const SUI_FEATURES = ["sui:signTransaction"];
21230
21123
  function isSuiStandardWallet(wallet) {
@@ -22303,8 +22196,6 @@ var QueryKeys;
22303
22196
  QueryKeys["XrplAccountActivatedInfo"] = "xrplAccountActivatedInfo";
22304
22197
  QueryKeys["FiatToCryptoPaymentMethods"] = "fiatToCryptoPaymentMethods";
22305
22198
  QueryKeys["Stellar"] = "stellar";
22306
- QueryKeys["StellarTrustLine"] = "stellarTrustLine";
22307
- QueryKeys["IsStellarTrustLineApproved"] = "isStellarTrustLineApproved";
22308
22199
  QueryKeys["StellarAccountActivatedInfo"] = "stellarAccountActivatedInfo";
22309
22200
  QueryKeys["Hedera"] = "hedera";
22310
22201
  QueryKeys["IsHederaTokenAssociated"] = "isHederaTokenAssociated";
@@ -22412,7 +22303,7 @@ const keys = () => ({
22412
22303
  // ============
22413
22304
  // Approval
22414
22305
  // ============
22415
- routeApproved: (routeData, allowanceInWei, isAllowanceQueryEnabled, hasAllowance) => [
22306
+ routeApproved: (routeData, allowanceInWei) => [
22416
22307
  ...keys().transactions(),
22417
22308
  QueryKeys.RouteApproved,
22418
22309
  routeData?.params.fromAddress,
@@ -22420,8 +22311,6 @@ const keys = () => ({
22420
22311
  routeData?.params.fromToken,
22421
22312
  routeData?.params.fromAmount,
22422
22313
  allowanceInWei?.toString(),
22423
- isAllowanceQueryEnabled,
22424
- hasAllowance,
22425
22314
  ],
22426
22315
  sendTransactionGas: (chainId, tokenAddress, from) => [
22427
22316
  QueryKeys.All,
@@ -22494,23 +22383,6 @@ const keys = () => ({
22494
22383
  // ============
22495
22384
  // Stellar
22496
22385
  // ============
22497
- stellarTrustLine: (tokenAddress, chainId, address) => [
22498
- ...keys().stellar(),
22499
- QueryKeys.StellarTrustLine,
22500
- tokenAddress,
22501
- chainId,
22502
- address,
22503
- ],
22504
- isStellarTrustLineApproved: (address, chainId, chainType, tokenAddress, trustLineLimit, amountToApprove) => [
22505
- ...keys().stellar(),
22506
- QueryKeys.IsStellarTrustLineApproved,
22507
- address,
22508
- chainId,
22509
- chainType,
22510
- tokenAddress,
22511
- trustLineLimit,
22512
- amountToApprove?.toString(),
22513
- ],
22514
22386
  stellarAccountActivatedInfo: (address, chainId, chainType) => [
22515
22387
  ...keys().stellar(),
22516
22388
  QueryKeys.StellarAccountActivatedInfo,
@@ -22546,8 +22418,6 @@ const getPrefixKey = (key) => {
22546
22418
  return [...keys().transactions(), key];
22547
22419
  case QueryKeys.XrplTrustLine:
22548
22420
  return [...keys().xrpl(), key];
22549
- case QueryKeys.StellarTrustLine:
22550
- return [...keys().stellar(), key];
22551
22421
  case QueryKeys.IsHederaTokenAssociated:
22552
22422
  return [...keys().hedera(), key];
22553
22423
  default:
@@ -23262,7 +23132,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23262
23132
  };
23263
23133
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23264
23134
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23265
- const { fetchAllSecretBalances } = await import('./secretService-D8hWz2Gz.js');
23135
+ const { fetchAllSecretBalances } = await import('./secretService-B3sc6ibT.js');
23266
23136
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23267
23137
  };
23268
23138
  function getTokenAssetsKey(token) {
@@ -26547,7 +26417,7 @@ function useStellarWallets() {
26547
26417
  try {
26548
26418
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
26549
26419
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
26550
- const { formatStellarWallet } = await import('./stellarService.client-Dve9IZZm.js');
26420
+ const { formatStellarWallet } = await import('./stellarService.client-Ciqw9lmL.js');
26551
26421
  const modules = [...initializeAllModules(), new LedgerModule()];
26552
26422
  const promises = modules.map(async (module) => {
26553
26423
  const isAvailable = await module.isAvailable();
@@ -28047,7 +27917,7 @@ function hederaWalletConnect(parameters) {
28047
27917
  const optionalChains = config.chains.map((x) => x.id);
28048
27918
  if (!optionalChains.length)
28049
27919
  return;
28050
- const { EthereumProvider } = await import('./index.es-CMuCSzqv.js');
27920
+ const { EthereumProvider } = await import('./index.es-DRgOycmm.js');
28051
27921
  const rawProvider = await EthereumProvider.init({
28052
27922
  ...restParameters,
28053
27923
  disableProviderPing: true,
@@ -29410,15 +29280,12 @@ const getAllXrplTokensBalance = async (userAddress, xrplTokens, xrplChains) => {
29410
29280
  };
29411
29281
  const getStellarTokenBalance = async (userAddress, token, chain) => {
29412
29282
  const stellarClient = await getClient(chain);
29413
- if (!isStellarToken(token)) {
29414
- throw new Error("Token must be a Stellar token");
29415
- }
29416
- const balance = await stellarClient.getBalance(userAddress, token.chainAssetConfig.stellar.contractAddress, chain.chainId);
29283
+ const balance = await stellarClient.getBalance(userAddress, token.address, chain.chainId);
29417
29284
  return BigInt(balance);
29418
29285
  };
29419
29286
  const getAllStellarTokensBalance = async (userAddress, stellarTokens, stellarChains) => {
29420
29287
  const getBalancesForChain = async (chain) => {
29421
- const tokensForChain = stellarTokens.filter((t) => t.chainId === chain.chainId && isStellarToken(t));
29288
+ const tokensForChain = stellarTokens.filter((t) => t.chainId === chain.chainId);
29422
29289
  const stellarClient = await getClient(chain);
29423
29290
  const allBalances = await stellarClient.getAllBalances(userAddress, tokensForChain);
29424
29291
  return allBalances.map((token) => {
@@ -29473,7 +29340,7 @@ class StellarRpcClient {
29473
29340
  .build();
29474
29341
  const simulateTxResponse = await this.server.simulateTransaction(tx);
29475
29342
  if ("error" in simulateTxResponse) {
29476
- const isNoBalanceError = /trying to get non-existing value for contract instance|trustline entry is missing for account/.test(simulateTxResponse.error);
29343
+ const isNoBalanceError = simulateTxResponse.error.includes("trying to get non-existing value for contract instance");
29477
29344
  // If the error message indicates that the user has no balance just return 0
29478
29345
  // We don't want to spam with this error as it's pretty common
29479
29346
  if (isNoBalanceError) {
@@ -29489,7 +29356,7 @@ class StellarRpcClient {
29489
29356
  }
29490
29357
  async getAllBalances(userAddress, tokens) {
29491
29358
  const balancePromises = tokens.map((token) => {
29492
- return this.getBalance(userAddress, token.chainAssetConfig.stellar.contractAddress, token.chainId);
29359
+ return this.getBalance(userAddress, token.address, token.chainId);
29493
29360
  });
29494
29361
  const results = await Promise.allSettled(balancePromises);
29495
29362
  const balances = results.map((result) => {
@@ -29589,9 +29456,9 @@ class XrplRpcClient {
29589
29456
  },
29590
29457
  ]);
29591
29458
  }
29592
- async getTrustLine(address, asset) {
29593
- const response = await this.getTrustLines(address, asset.issuer);
29594
- const trustLine = response.lines.find((line) => line.currency === asset.code);
29459
+ async getTrustLine(address, issuer, currency) {
29460
+ const response = await this.getTrustLines(address, issuer);
29461
+ const trustLine = response.lines.find((line) => line.currency === currency);
29595
29462
  return trustLine ?? null;
29596
29463
  }
29597
29464
  async accountActivatedInfo(address) {
@@ -29767,26 +29634,9 @@ class StellarApiClient {
29767
29634
  const baseReserveBn = BigInt(latestLedger.base_reserve_in_stroops);
29768
29635
  return baseReserveBn;
29769
29636
  }
29770
- async getTrustLines(userAddress) {
29771
- const response = await fetch(`${this.apiUrl}/accounts/${userAddress}`);
29772
- if (!response.ok) {
29773
- throw new Error(`Failed to fetch account data: ${response.statusText}`);
29774
- }
29775
- const data = await response.json();
29776
- if (!Array.isArray(data?.balances)) {
29777
- throw new Error("Invalid response from Horizon API");
29778
- }
29779
- const assets = data.balances.filter(isValidHorizonAsset);
29780
- return assets.filter(isValidIssuedAsset);
29781
- }
29782
- async getTrustLine(address, asset) {
29783
- const trustLines = await this.getTrustLines(address);
29784
- const trustLine = trustLines.find((line) => line.asset_code === asset.code && line.asset_issuer === asset.issuer);
29785
- return trustLine ?? null;
29786
- }
29787
29637
  }
29788
29638
 
29789
- const DEFAULT_REFETCH_INTERVAL$2 = 20_000;
29639
+ const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
29790
29640
  function useStellarAccountActivation({ address, chain, token, }) {
29791
29641
  /**
29792
29642
  * Checks if the destination account exists on the Stellar network
@@ -29802,8 +29652,9 @@ function useStellarAccountActivation({ address, chain, token, }) {
29802
29652
  if (!address) {
29803
29653
  throw new Error("Destination address is required");
29804
29654
  }
29805
- const horizonApiUrl = getStellarHorizonApiUrl(chain);
29806
- if (!horizonApiUrl) {
29655
+ // TODO: update types
29656
+ const [horizonApiUrl] = chain?.horizonRpcList;
29657
+ if (typeof horizonApiUrl !== "string") {
29807
29658
  throw new Error("Invalid Horizon API URL");
29808
29659
  }
29809
29660
  const stellarApiClient = new StellarApiClient(horizonApiUrl);
@@ -29819,7 +29670,7 @@ function useStellarAccountActivation({ address, chain, token, }) {
29819
29670
  };
29820
29671
  },
29821
29672
  enabled: !!address && chain?.chainType === ChainType.STELLAR,
29822
- refetchInterval: DEFAULT_REFETCH_INTERVAL$2,
29673
+ refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
29823
29674
  refetchOnWindowFocus: true,
29824
29675
  });
29825
29676
  return {
@@ -29827,149 +29678,6 @@ function useStellarAccountActivation({ address, chain, token, }) {
29827
29678
  };
29828
29679
  }
29829
29680
 
29830
- /**
29831
- * Maximum asset amount on Stellar
29832
- * @see https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/assets#amount-precision
29833
- */
29834
- const MAX_ASSET_AMOUNT = "922337203685.4775807";
29835
- const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
29836
- function useStellarTrustLine({ address, chain, token, amount }) {
29837
- const { stellarSigner } = useSigner({ chain });
29838
- const queryClient = useQueryClient();
29839
- /**
29840
- * Retrieves the destination account's trust line data for the given token
29841
- */
29842
- const trustLineQuery = useQuery({
29843
- queryKey: keys().stellarTrustLine(token?.address, chain?.chainId, address),
29844
- queryFn: async () => {
29845
- if (chain?.chainType !== ChainType.STELLAR ||
29846
- token?.type !== ChainType.STELLAR) {
29847
- return null;
29848
- }
29849
- if (!address || !isStellarAddressValid(address)) {
29850
- return null;
29851
- }
29852
- // Only issued tokens require trust lines
29853
- // Other token types like contract tokens don't need trust lines
29854
- if (!isStellarIssuedToken(token)) {
29855
- return null;
29856
- }
29857
- const asset = getStellarTrustLineAsset(token);
29858
- if (!asset) {
29859
- throw new Error("Invalid asset");
29860
- }
29861
- const horizonApiUrl = getStellarHorizonApiUrl(chain);
29862
- if (!horizonApiUrl) {
29863
- throw new Error("Invalid Horizon API URL");
29864
- }
29865
- const stellarApiClient = new StellarApiClient(horizonApiUrl);
29866
- return stellarApiClient.getTrustLine(address, asset);
29867
- },
29868
- enabled: !!address &&
29869
- chain?.chainType === ChainType.STELLAR &&
29870
- token?.type === ChainType.STELLAR,
29871
- refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
29872
- });
29873
- /**
29874
- * Creates a trust line where the destination account authorizes to receive the given token
29875
- */
29876
- const createTrustLine = useMutation({
29877
- mutationFn: async () => {
29878
- try {
29879
- if (!stellarSigner) {
29880
- throw new Error("Stellar signer not found");
29881
- }
29882
- if (!address) {
29883
- throw new Error("Destination address is required");
29884
- }
29885
- if (chain?.chainType !== ChainType.STELLAR ||
29886
- token?.type !== ChainType.STELLAR) {
29887
- throw new Error("Chain and token to approve must be a Stellar token");
29888
- }
29889
- if (!isStellarIssuedToken(token)) {
29890
- throw new Error("Token must be a Stellar issued token");
29891
- }
29892
- const assetInfo = getStellarTrustLineAsset(token);
29893
- if (!assetInfo) {
29894
- throw new Error("Invalid asset");
29895
- }
29896
- const network = getStellarNetwork(chain.chainId);
29897
- if (network == null) {
29898
- throw new Error(`Stellar network not found for chain ${chain.chainId}`);
29899
- }
29900
- const client = await getClient(chain);
29901
- const account = await client.getAccount(address);
29902
- const asset = new Asset(assetInfo.code, assetInfo.issuer);
29903
- const changeTrustOperation = Operation.changeTrust({
29904
- asset,
29905
- limit: MAX_ASSET_AMOUNT,
29906
- });
29907
- const builtTransaction = new TransactionBuilder(account, {
29908
- fee: (BigInt(BASE_FEE) * BigInt(2)).toString(),
29909
- networkPassphrase: network,
29910
- })
29911
- .addOperation(changeTrustOperation)
29912
- .setTimeout(300)
29913
- .build();
29914
- const { signedTxXdr } = await stellarSigner.signTransaction(builtTransaction.toXDR(), {
29915
- networkPassphrase: network,
29916
- });
29917
- const signedTransaction = new Transaction$1(signedTxXdr, network);
29918
- const sentTransaction = await client.sendTransaction(signedTransaction);
29919
- const txStatus = await client.waitForTransaction(sentTransaction.hash, {
29920
- interval: 1_000,
29921
- });
29922
- if (txStatus !== rpc.Api.GetTransactionStatus.SUCCESS) {
29923
- throw new Error(`Transaction failed with status: ${txStatus}`);
29924
- }
29925
- return true;
29926
- }
29927
- catch (error) {
29928
- console.error("Error creating trust line:", error);
29929
- return false;
29930
- }
29931
- },
29932
- async onSuccess() {
29933
- queryClient.invalidateQueries({
29934
- queryKey: getPrefixKey(QueryKeys.StellarTrustLine),
29935
- });
29936
- },
29937
- });
29938
- /**
29939
- * Checks if the destination account has created a trust line to receive the given token.
29940
- */
29941
- const isTrustLineApproved = useQuery({
29942
- queryKey: keys().isStellarTrustLineApproved(address, token?.chainId, token?.type, token?.address, trustLineQuery.data?.limit, amount),
29943
- queryFn: async () => {
29944
- if (token?.type !== ChainType.STELLAR) {
29945
- return true;
29946
- }
29947
- // The native Stellar token doesn't need a trust line
29948
- if (token.address.toLowerCase() === nativeStellarTokenAddress.toLowerCase()) {
29949
- return true;
29950
- }
29951
- if (!amount) {
29952
- throw new Error("Amount is required");
29953
- }
29954
- const limitBn = BigNumber$1(trustLineQuery.data?.limit || "0");
29955
- const balanceBn = BigNumber$1(trustLineQuery.data?.balance || "0");
29956
- const availableAllowanceBn = limitBn.minus(balanceBn);
29957
- const amountBn = BigNumber$1(formatBNToReadable(amount, token.decimals));
29958
- return availableAllowanceBn.gte(amountBn);
29959
- },
29960
- enabled: !!address &&
29961
- !!amount &&
29962
- !trustLineQuery?.isLoading &&
29963
- trustLineQuery?.isFetched &&
29964
- token?.type === ChainType.STELLAR,
29965
- });
29966
- return {
29967
- createTrustLine,
29968
- trustLineQuery,
29969
- isTrustLineApproved,
29970
- };
29971
- }
29972
-
29973
29681
  const useAddressBookStore = create(persist((set) => ({
29974
29682
  addressBook: [],
29975
29683
  add: (newAddressData) => {
@@ -31592,18 +31300,15 @@ async function sendTransactionXrpl({ amount, signer, to, token, from, }) {
31592
31300
  txHash: hash,
31593
31301
  };
31594
31302
  }
31595
- const asset = parseXrplTokenAddress(token.address);
31596
- if (!asset) {
31597
- throw new Error("Invalid asset");
31598
- }
31303
+ const [currency, issuer] = token.address.split(".");
31599
31304
  const amountFormatted = formatBNToReadable(amount, token.decimals);
31600
31305
  const { hash } = await signer.signAndSubmit({
31601
31306
  network: xrplNetwork,
31602
31307
  tx: {
31603
31308
  ...baseTransaction,
31604
31309
  Amount: {
31605
- currency: asset.code,
31606
- issuer: asset.issuer,
31310
+ currency,
31311
+ issuer,
31607
31312
  value: amountFormatted,
31608
31313
  },
31609
31314
  },
@@ -32336,7 +32041,7 @@ const useApproval = ({ squidRoute, }) => {
32336
32041
  * On Error: Showing the error message if any
32337
32042
  * @returns {boolean} approved
32338
32043
  */
32339
- const routeApproved = useQuery(keys().routeApproved(squidRoute, allowanceInWei, erc20AllowanceQueryEnabled, hasAllowance), async () => {
32044
+ const routeApproved = useQuery(keys().routeApproved(squidRoute, allowanceInWei), async () => {
32340
32045
  if (erc20AllowanceQueryEnabled) {
32341
32046
  return hasAllowance;
32342
32047
  }
@@ -36844,12 +36549,12 @@ function useXrplTrustLine({ address, chain, token, amount }) {
36844
36549
  if (!address || !isXrplAddressValid(address)) {
36845
36550
  return null;
36846
36551
  }
36847
- const trustLineAsset = parseXrplTokenAddress(token.address);
36848
- if (!trustLineAsset) {
36552
+ const [currency, issuer] = token.address.split(".");
36553
+ if (!currency || !issuer) {
36849
36554
  return null;
36850
36555
  }
36851
36556
  const xrplClient = await getClient(chain);
36852
- const trustLine = await xrplClient.getTrustLine(address, trustLineAsset);
36557
+ const trustLine = await xrplClient.getTrustLine(address, issuer, currency);
36853
36558
  return trustLine;
36854
36559
  },
36855
36560
  enabled: !!address &&
@@ -37087,5 +36792,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
37087
36792
  React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
37088
36793
  };
37089
36794
 
37090
- export { useAllConnectedWalletBalances as $, AxelarStatusResponseType as A, useSquidQueryClient as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useSquid as E, useStellarAccountActivation as F, useStellarTrustLine as G, HistoryTxType as H, useAddressBookStore as I, useAssetsColorsStore as J, useFavoriteTokensStore as K, useHistoryStore as L, useSendTransactionStore as M, Nr as N, useConfigStore as O, useSquidStore as P, QueryKeys as Q, useSwapRoutePersistStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useTransactionStore as U, ConnectingWalletStatus as V, Wo as W, XamanXrplNetwork as X, useWalletStore as Y, useDepositAddress as Z, useSwap as _, WindowWalletFlag as a, getSupportedChainIdsForDirection as a$, useAllTokensWithBalanceForChainType as a0, useCosmosBalance as a1, useEvmBalance as a2, useMultiChainBalance as a3, useMultipleTokenPrices as a4, useNativeBalance as a5, useNativeTokenForChain as a6, useSingleTokenPrice as a7, useSquidTokens as a8, useHistoricalData as a9, useSigner as aA, useWallet as aB, useWallets as aC, useXrplTrustLine as aD, TX_STATUS_CONSTANTS as aE, FINAL_TRANSACTION_STATUSES as aF, useGetFiatQuote as aG, useGetOnRampConfig as aH, useExecuteFiatQuote as aI, useFiatOnRampTxStatus as aJ, useFiatTransactions as aK, useCurrencyDetails as aL, useCountryDetails as aM, useAvailableQuotes as aN, useRecommendedQuote as aO, useGetOnrampPaymentTypes as aP, useSuggestedFiatAmounts as aQ, SquidProvider as aR, EnsService as aS, getXummClient as aT, isXamanXAppContext as aU, getQueryHeaders as aV, getStatusCode as aW, is404Error as aX, assetsBaseUrl as aY, shareSubgraphId as aZ, sortTokensBySharedSubgraphIds as a_, useTokensData as aa, useEstimateSendTransaction as ab, useSendTransaction as ac, useSendTransactionGas as ad, useAllTransactionsStatus as ae, useApproval as af, useEstimate as ag, useEstimatePriceImpact as ah, useExecuteTransaction as ai, useGetRoute as aj, useGetRouteWrapper as ak, useRouteWarnings as al, useSendTransactionStatus as am, useSwapTransactionStatus as an, useAvatar as ao, useHistory as ap, useUserParams as aq, useDebouncedValue as ar, useAddToken as as, useAutoConnect as at, useEnsDataForAddress as au, useEnsSearch as av, useGnosisContext as aw, useIsSameAddressAndGnosisContext as ax, useIntegratorContext as ay, useMultiChainWallet as az, chainTypeToZeroAddressMap as b, formatTokenAmount as b$, filterChains as b0, filterTokens as b1, getTokenImage as b2, getNewSwapParamsFromInput as b3, sortAllTokens as b4, findToken as b5, findNativeToken as b6, normalizeIbcAddress as b7, groupTokensBySymbol as b8, groupTokensByChainId as b9, suggestChainOrThrow as bA, normalizeError as bB, transactionErrorCode as bC, isUserRejectionError as bD, getTransactionError as bE, handleTransactionErrorEvents as bF, isSwapRouteError as bG, isStatusError as bH, createQuoteRequestParamsHash as bI, WidgetEvents as bJ, EvmNetworkNotSupportedErrorCode as bK, addEthereumChain as bL, parseEvmAddress as bM, formatEvmWallet as bN, filterWagmiConnector as bO, waitForReceiptWithRetry as bP, getUserCountry as bQ, getCountryData as bR, getCurrencyData as bS, adaptiveRound as bT, getSuggestedAmountsForCurrency as bU, HederaExtensionHelper as bV, convertHederaAccountIdToEvmAddress as bW, convertEvmAddressToHederaAccountId as bX, parseToBigInt as bY, roundNumericValue as bZ, formatUnitsRounded as b_, filterViewableTokens as ba, getSecretNetworkBalances as bb, getTokenAssetsKey as bc, fetchAssetsColors as bd, initializeSquidWithAssetsColors as be, isEmptyObject as bf, normalizeTokenSymbol as bg, areTokenSymbolsCompatible as bh, isEvmosChain as bi, getConfigWithDefaults as bj, randomIntFromInterval as bk, getTokensForChain as bl, getFirstAvailableChainId as bm, fetchHighestBalanceToken as bn, getInitialOrDefaultTokenAddressForChain as bo, getInitialTokenAddressForChain as bp, filterTokensForDestination as bq, getInitialChainIdFromConfig as br, getCosmosKey as bs, getKeysSettled as bt, getAllKeysForSupportedCosmosChains as bu, isCosmosAddressValid as bv, getCosmosSigningClient as bw, getCosmosChainInfosObject as bx, connectCosmosWallet as by, isFallbackAddressNeeded as bz, chainTypeToNativeTokenAddressMap as c, walletSupportsChainType as c$, formatUsdAmount as c0, trimExtraDecimals as c1, getNumericValue as c2, cleanAmount as c3, convertTokenAmountToUSD as c4, convertUSDToTokenAmount as c5, calculateTotal24hChange as c6, searchTokens as c7, filterSolanaWallets as c8, isSolanaAddressValid as c9, getStepStatuses as cA, getHalfSuccessState as cB, getStepsInfos as cC, getSwapTxStatusRefetchInterval as cD, getSendTxStatusRefetchInterval as cE, chainflipMultihopBridgeType as cF, getBridgeType as cG, getTransactionStatus as cH, getTransactionEndStatus as cI, isHistoryTransactionPending as cJ, isHistoryTransactionFailed as cK, isHistoryTransactionWarning as cL, isHistoryTransactionEnded as cM, formatHash as cN, isWalletAddressValid as cO, redirectToExtensionsStore as cP, accessProperty as cQ, populateWallets as cR, getDefaultChain as cS, sortWallets as cT, areSameAddress as cU, sortAddressBook as cV, calculateTotalUsdBalanceUSD as cW, addTokenToWallet as cX, isEvmChainNotSupportedError as cY, getWalletSupportedChainTypes as cZ, getConnectorForChainType as c_, executeSolanaSwap as ca, executeSolanaTransfer as cb, isStellarAddressValid as cc, getStellarNetwork as cd, stellarAddressToScVal as ce, getStellarTrustLineAsset as cf, isStellarToken as cg, isStellarIssuedToken as ch, getStellarHorizonApiUrl as ci, isValidIssuedAsset as cj, isValidHorizonAsset as ck, formatTransactionHistoryDate as cl, getAxelarExplorerTxUrl as cm, getSourceExplorerTxUrl as cn, getMainExplorerUrl as co, formatDistance as cp, formatSeconds as cq, formatSwapTxStatusResponseForStorage as cr, simplifyRouteAction as cs, fetchSwapTransactionStatus as ct, compareTransactionIds as cu, isCoralBridgeAction as cv, sleep as cw, isDepositRoute as cx, isChainflipBridgeTransaction as cy, getHistoryTransactionId as cz, definedInWindow as d, connectWallet as d0, cancelConnectWallet as d1, isProblematicConnector as d2, mergeWallets as d3, isXionSmartContractAddress as d4, isXrplAddressValid as d5, buildXrplTrustSetTx as d6, getXrplNetwork as d7, parseXrplPaymentTx as d8, parseXrplTokenAddress as d9, er as e, formatBNToReadable as f, destinationAddressResetValue as g, fallbackAddressResetValue as h, nativeCosmosTokenAddress as i, nativeEvmTokenAddress as j, nativeSolanaTokenAddress as k, nativeStellarTokenAddress as l, nativeSuiTokenAddress as m, nativeBitcoinTokenAddress as n, nativeXrplTokenAddress as o, CosmosProvider as p, SendTransactionStatus as q, TransactionStatus as r, useTrackSearchEmpty as s, useSquidChains as t, useCosmosContext as u, useClient as v, walletIconBaseUrl as w, useCosmosForChain as x, useHederaTokenAssociations as y, useKeyboardNavigation as z };
37091
- //# sourceMappingURL=index-DPakWLan.js.map
36795
+ export { useAllTokensWithBalanceForChainType as $, AxelarStatusResponseType as A, useSquidQueryClient as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useSquid as E, useStellarAccountActivation as F, useAddressBookStore as G, HistoryTxType as H, useAssetsColorsStore as I, useFavoriteTokensStore as J, useHistoryStore as K, useSendTransactionStore as L, useConfigStore as M, Nr as N, useSquidStore as O, useSwapRoutePersistStore as P, QueryKeys as Q, useTransactionStore as R, SquidStatusErrorType as S, TransactionErrorType as T, ConnectingWalletStatus as U, useWalletStore as V, Wo as W, XamanXrplNetwork as X, useDepositAddress as Y, useSwap as Z, useAllConnectedWalletBalances as _, WindowWalletFlag as a, filterChains as a$, useCosmosBalance as a0, useEvmBalance as a1, useMultiChainBalance as a2, useMultipleTokenPrices as a3, useNativeBalance as a4, useNativeTokenForChain as a5, useSingleTokenPrice as a6, useSquidTokens as a7, useHistoricalData as a8, useTokensData as a9, useWallet as aA, useWallets as aB, useXrplTrustLine as aC, TX_STATUS_CONSTANTS as aD, FINAL_TRANSACTION_STATUSES as aE, useGetFiatQuote as aF, useGetOnRampConfig as aG, useExecuteFiatQuote as aH, useFiatOnRampTxStatus as aI, useFiatTransactions as aJ, useCurrencyDetails as aK, useCountryDetails as aL, useAvailableQuotes as aM, useRecommendedQuote as aN, useGetOnrampPaymentTypes as aO, useSuggestedFiatAmounts as aP, SquidProvider as aQ, EnsService as aR, getXummClient as aS, isXamanXAppContext as aT, getQueryHeaders as aU, getStatusCode as aV, is404Error as aW, assetsBaseUrl as aX, shareSubgraphId as aY, sortTokensBySharedSubgraphIds as aZ, getSupportedChainIdsForDirection as a_, useEstimateSendTransaction as aa, useSendTransaction as ab, useSendTransactionGas as ac, useAllTransactionsStatus as ad, useApproval as ae, useEstimate as af, useEstimatePriceImpact as ag, useExecuteTransaction as ah, useGetRoute as ai, useGetRouteWrapper as aj, useRouteWarnings as ak, useSendTransactionStatus as al, useSwapTransactionStatus as am, useAvatar as an, useHistory as ao, useUserParams as ap, useDebouncedValue as aq, useAddToken as ar, useAutoConnect as as, useEnsDataForAddress as at, useEnsSearch as au, useGnosisContext as av, useIsSameAddressAndGnosisContext as aw, useIntegratorContext as ax, useMultiChainWallet as ay, useSigner as az, chainTypeToZeroAddressMap as b, formatUsdAmount as b$, filterTokens as b0, getTokenImage as b1, getNewSwapParamsFromInput as b2, sortAllTokens as b3, findToken as b4, findNativeToken as b5, normalizeIbcAddress as b6, groupTokensBySymbol as b7, groupTokensByChainId as b8, filterViewableTokens as b9, normalizeError as bA, transactionErrorCode as bB, isUserRejectionError as bC, getTransactionError as bD, handleTransactionErrorEvents as bE, isSwapRouteError as bF, isStatusError as bG, createQuoteRequestParamsHash as bH, WidgetEvents as bI, EvmNetworkNotSupportedErrorCode as bJ, addEthereumChain as bK, parseEvmAddress as bL, formatEvmWallet as bM, filterWagmiConnector as bN, waitForReceiptWithRetry as bO, getUserCountry as bP, getCountryData as bQ, getCurrencyData as bR, adaptiveRound as bS, getSuggestedAmountsForCurrency as bT, HederaExtensionHelper as bU, convertHederaAccountIdToEvmAddress as bV, convertEvmAddressToHederaAccountId as bW, parseToBigInt as bX, roundNumericValue as bY, formatUnitsRounded as bZ, formatTokenAmount as b_, getSecretNetworkBalances as ba, getTokenAssetsKey as bb, fetchAssetsColors as bc, initializeSquidWithAssetsColors as bd, isEmptyObject as be, normalizeTokenSymbol as bf, areTokenSymbolsCompatible as bg, isEvmosChain as bh, getConfigWithDefaults as bi, randomIntFromInterval as bj, getTokensForChain as bk, getFirstAvailableChainId as bl, fetchHighestBalanceToken as bm, getInitialOrDefaultTokenAddressForChain as bn, getInitialTokenAddressForChain as bo, filterTokensForDestination as bp, getInitialChainIdFromConfig as bq, getCosmosKey as br, getKeysSettled as bs, getAllKeysForSupportedCosmosChains as bt, isCosmosAddressValid as bu, getCosmosSigningClient as bv, getCosmosChainInfosObject as bw, connectCosmosWallet as bx, isFallbackAddressNeeded as by, suggestChainOrThrow as bz, chainTypeToNativeTokenAddressMap as c, trimExtraDecimals as c0, getNumericValue as c1, cleanAmount as c2, convertTokenAmountToUSD as c3, convertUSDToTokenAmount as c4, calculateTotal24hChange as c5, searchTokens as c6, filterSolanaWallets as c7, isSolanaAddressValid as c8, executeSolanaSwap as c9, isHistoryTransactionFailed as cA, isHistoryTransactionWarning as cB, isHistoryTransactionEnded as cC, formatHash as cD, isWalletAddressValid as cE, redirectToExtensionsStore as cF, accessProperty as cG, populateWallets as cH, getDefaultChain as cI, sortWallets as cJ, areSameAddress as cK, sortAddressBook as cL, calculateTotalUsdBalanceUSD as cM, addTokenToWallet as cN, isEvmChainNotSupportedError as cO, getWalletSupportedChainTypes as cP, getConnectorForChainType as cQ, walletSupportsChainType as cR, connectWallet as cS, cancelConnectWallet as cT, isProblematicConnector as cU, mergeWallets as cV, isXionSmartContractAddress as cW, isXrplAddressValid as cX, buildXrplTrustSetTx as cY, getXrplNetwork as cZ, parseXrplPaymentTx as c_, executeSolanaTransfer as ca, formatTransactionHistoryDate as cb, getAxelarExplorerTxUrl as cc, getSourceExplorerTxUrl as cd, getMainExplorerUrl as ce, formatDistance as cf, formatSeconds as cg, formatSwapTxStatusResponseForStorage as ch, simplifyRouteAction as ci, fetchSwapTransactionStatus as cj, compareTransactionIds as ck, isCoralBridgeAction as cl, sleep as cm, isDepositRoute as cn, isChainflipBridgeTransaction as co, getHistoryTransactionId as cp, getStepStatuses as cq, getHalfSuccessState as cr, getStepsInfos as cs, getSwapTxStatusRefetchInterval as ct, getSendTxStatusRefetchInterval as cu, chainflipMultihopBridgeType as cv, getBridgeType as cw, getTransactionStatus as cx, getTransactionEndStatus as cy, isHistoryTransactionPending as cz, definedInWindow as d, er as e, formatBNToReadable as f, destinationAddressResetValue as g, fallbackAddressResetValue as h, nativeCosmosTokenAddress as i, nativeEvmTokenAddress as j, nativeSolanaTokenAddress as k, nativeStellarTokenAddress as l, nativeSuiTokenAddress as m, nativeBitcoinTokenAddress as n, nativeXrplTokenAddress as o, CosmosProvider as p, SendTransactionStatus as q, TransactionStatus as r, useTrackSearchEmpty as s, useSquidChains as t, useCosmosContext as u, useClient as v, walletIconBaseUrl as w, useCosmosForChain as x, useHederaTokenAssociations as y, useKeyboardNavigation as z };
36796
+ //# sourceMappingURL=index-CMrdTYeW.js.map