@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
@@ -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 {
@@ -21131,28 +21118,6 @@ const executeSolanaTransfer = async ({ amount, target, signer, connection, sourc
21131
21118
  return signature;
21132
21119
  };
21133
21120
 
21134
- var StellarHorizonAssetType;
21135
- (function (StellarHorizonAssetType) {
21136
- /**
21137
- * XLM native token
21138
- */
21139
- StellarHorizonAssetType["NATIVE"] = "native";
21140
- /**
21141
- * 1-4 char asset code (e.g. USDC)
21142
- */
21143
- StellarHorizonAssetType["ALPHANUM4"] = "credit_alphanum4";
21144
- /**
21145
- * 5-12 char asset code (e.g. wstETH)
21146
- */
21147
- StellarHorizonAssetType["ALPHANUM12"] = "credit_alphanum12";
21148
- })(StellarHorizonAssetType || (StellarHorizonAssetType = {}));
21149
- var StellarTokenType;
21150
- (function (StellarTokenType) {
21151
- StellarTokenType["NATIVE_TOKEN"] = "nativeToken";
21152
- StellarTokenType["ISSUER_TOKEN"] = "issuerToken";
21153
- StellarTokenType["CONTRACT_TOKEN"] = "contractToken";
21154
- })(StellarTokenType || (StellarTokenType = {}));
21155
-
21156
21121
  function isStellarAddressValid(address) {
21157
21122
  return stellarSdk.StrKey.isValidEd25519PublicKey(address);
21158
21123
  }
@@ -21174,78 +21139,6 @@ function stellarAddressToScVal(addressString) {
21174
21139
  type: "address",
21175
21140
  });
21176
21141
  }
21177
- function getStellarTrustLineAsset(token) {
21178
- // The address format for issued assets is `CODE-ISSUER`
21179
- // Example: USDC-GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN
21180
- const [code, issuer] = token.address.split("-");
21181
- if (!code || !issuer) {
21182
- return null;
21183
- }
21184
- return {
21185
- code,
21186
- issuer,
21187
- };
21188
- }
21189
- function isStellarToken(token) {
21190
- try {
21191
- const stellarToken = token;
21192
- return (Object.values(StellarTokenType).includes(stellarToken.chainAssetConfig.stellar.assetType) &&
21193
- typeof stellarToken.chainAssetConfig.stellar.contractAddress === "string");
21194
- }
21195
- catch {
21196
- return false;
21197
- }
21198
- }
21199
- function isStellarIssuedToken(token) {
21200
- try {
21201
- return (isStellarToken(token) &&
21202
- token.chainAssetConfig.stellar.assetType === StellarTokenType.ISSUER_TOKEN);
21203
- }
21204
- catch {
21205
- return false;
21206
- }
21207
- }
21208
- function getStellarHorizonApiUrl(chain) {
21209
- try {
21210
- const stellarChain = chain;
21211
- const [horizonApiUrl] = stellarChain.horizonRpcList;
21212
- if (typeof horizonApiUrl !== "string") {
21213
- throw new Error("Invalid Horizon API URL");
21214
- }
21215
- return horizonApiUrl;
21216
- }
21217
- catch {
21218
- return null;
21219
- }
21220
- }
21221
- const VALID_ASSET_TYPES = new Set(Object.values(StellarHorizonAssetType));
21222
- function isValidNativeAsset(asset) {
21223
- return (typeof asset === "object" &&
21224
- asset !== null &&
21225
- "balance" in asset &&
21226
- typeof asset.balance === "string" &&
21227
- "asset_type" in asset &&
21228
- asset.asset_type === StellarHorizonAssetType.NATIVE);
21229
- }
21230
- function isValidIssuedAsset(asset) {
21231
- return (typeof asset === "object" &&
21232
- asset !== null &&
21233
- "balance" in asset &&
21234
- typeof asset.balance === "string" &&
21235
- "asset_type" in asset &&
21236
- typeof asset.asset_type === "string" &&
21237
- VALID_ASSET_TYPES.has(asset.asset_type) &&
21238
- asset.asset_type !== StellarHorizonAssetType.NATIVE &&
21239
- "asset_code" in asset &&
21240
- typeof asset.asset_code === "string" &&
21241
- "asset_issuer" in asset &&
21242
- typeof asset.asset_issuer === "string" &&
21243
- "limit" in asset &&
21244
- typeof asset.limit === "string");
21245
- }
21246
- function isValidHorizonAsset(asset) {
21247
- return isValidNativeAsset(asset) || isValidIssuedAsset(asset);
21248
- }
21249
21142
 
21250
21143
  const SUI_FEATURES = ["sui:signTransaction"];
21251
21144
  function isSuiStandardWallet(wallet) {
@@ -22324,8 +22217,6 @@ exports.QueryKeys = void 0;
22324
22217
  QueryKeys["XrplAccountActivatedInfo"] = "xrplAccountActivatedInfo";
22325
22218
  QueryKeys["FiatToCryptoPaymentMethods"] = "fiatToCryptoPaymentMethods";
22326
22219
  QueryKeys["Stellar"] = "stellar";
22327
- QueryKeys["StellarTrustLine"] = "stellarTrustLine";
22328
- QueryKeys["IsStellarTrustLineApproved"] = "isStellarTrustLineApproved";
22329
22220
  QueryKeys["StellarAccountActivatedInfo"] = "stellarAccountActivatedInfo";
22330
22221
  QueryKeys["Hedera"] = "hedera";
22331
22222
  QueryKeys["IsHederaTokenAssociated"] = "isHederaTokenAssociated";
@@ -22433,7 +22324,7 @@ const keys = () => ({
22433
22324
  // ============
22434
22325
  // Approval
22435
22326
  // ============
22436
- routeApproved: (routeData, allowanceInWei, isAllowanceQueryEnabled, hasAllowance) => [
22327
+ routeApproved: (routeData, allowanceInWei) => [
22437
22328
  ...keys().transactions(),
22438
22329
  exports.QueryKeys.RouteApproved,
22439
22330
  routeData?.params.fromAddress,
@@ -22441,8 +22332,6 @@ const keys = () => ({
22441
22332
  routeData?.params.fromToken,
22442
22333
  routeData?.params.fromAmount,
22443
22334
  allowanceInWei?.toString(),
22444
- isAllowanceQueryEnabled,
22445
- hasAllowance,
22446
22335
  ],
22447
22336
  sendTransactionGas: (chainId, tokenAddress, from) => [
22448
22337
  exports.QueryKeys.All,
@@ -22515,23 +22404,6 @@ const keys = () => ({
22515
22404
  // ============
22516
22405
  // Stellar
22517
22406
  // ============
22518
- stellarTrustLine: (tokenAddress, chainId, address) => [
22519
- ...keys().stellar(),
22520
- exports.QueryKeys.StellarTrustLine,
22521
- tokenAddress,
22522
- chainId,
22523
- address,
22524
- ],
22525
- isStellarTrustLineApproved: (address, chainId, chainType, tokenAddress, trustLineLimit, amountToApprove) => [
22526
- ...keys().stellar(),
22527
- exports.QueryKeys.IsStellarTrustLineApproved,
22528
- address,
22529
- chainId,
22530
- chainType,
22531
- tokenAddress,
22532
- trustLineLimit,
22533
- amountToApprove?.toString(),
22534
- ],
22535
22407
  stellarAccountActivatedInfo: (address, chainId, chainType) => [
22536
22408
  ...keys().stellar(),
22537
22409
  exports.QueryKeys.StellarAccountActivatedInfo,
@@ -22567,8 +22439,6 @@ const getPrefixKey = (key) => {
22567
22439
  return [...keys().transactions(), key];
22568
22440
  case exports.QueryKeys.XrplTrustLine:
22569
22441
  return [...keys().xrpl(), key];
22570
- case exports.QueryKeys.StellarTrustLine:
22571
- return [...keys().stellar(), key];
22572
22442
  case exports.QueryKeys.IsHederaTokenAssociated:
22573
22443
  return [...keys().hedera(), key];
22574
22444
  default:
@@ -23283,7 +23153,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23283
23153
  };
23284
23154
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23285
23155
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23286
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-CdbkGf17.js'); });
23156
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-B_-XWo1F.js'); });
23287
23157
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23288
23158
  };
23289
23159
  function getTokenAssetsKey(token) {
@@ -26568,7 +26438,7 @@ function useStellarWallets() {
26568
26438
  try {
26569
26439
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
26570
26440
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
26571
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-ESo7_qhK.js'); });
26441
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-sRzC5VSD.js'); });
26572
26442
  const modules = [...initializeAllModules(), new LedgerModule()];
26573
26443
  const promises = modules.map(async (module) => {
26574
26444
  const isAvailable = await module.isAvailable();
@@ -28068,7 +27938,7 @@ function hederaWalletConnect(parameters) {
28068
27938
  const optionalChains = config.chains.map((x) => x.id);
28069
27939
  if (!optionalChains.length)
28070
27940
  return;
28071
- const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-CT2n71aB.js'); });
27941
+ const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-Cu_QQTg-.js'); });
28072
27942
  const rawProvider = await EthereumProvider.init({
28073
27943
  ...restParameters,
28074
27944
  disableProviderPing: true,
@@ -29431,15 +29301,12 @@ const getAllXrplTokensBalance = async (userAddress, xrplTokens, xrplChains) => {
29431
29301
  };
29432
29302
  const getStellarTokenBalance = async (userAddress, token, chain) => {
29433
29303
  const stellarClient = await getClient(chain);
29434
- if (!isStellarToken(token)) {
29435
- throw new Error("Token must be a Stellar token");
29436
- }
29437
- const balance = await stellarClient.getBalance(userAddress, token.chainAssetConfig.stellar.contractAddress, chain.chainId);
29304
+ const balance = await stellarClient.getBalance(userAddress, token.address, chain.chainId);
29438
29305
  return BigInt(balance);
29439
29306
  };
29440
29307
  const getAllStellarTokensBalance = async (userAddress, stellarTokens, stellarChains) => {
29441
29308
  const getBalancesForChain = async (chain) => {
29442
- const tokensForChain = stellarTokens.filter((t) => t.chainId === chain.chainId && isStellarToken(t));
29309
+ const tokensForChain = stellarTokens.filter((t) => t.chainId === chain.chainId);
29443
29310
  const stellarClient = await getClient(chain);
29444
29311
  const allBalances = await stellarClient.getAllBalances(userAddress, tokensForChain);
29445
29312
  return allBalances.map((token) => {
@@ -29494,7 +29361,7 @@ class StellarRpcClient {
29494
29361
  .build();
29495
29362
  const simulateTxResponse = await this.server.simulateTransaction(tx);
29496
29363
  if ("error" in simulateTxResponse) {
29497
- const isNoBalanceError = /trying to get non-existing value for contract instance|trustline entry is missing for account/.test(simulateTxResponse.error);
29364
+ const isNoBalanceError = simulateTxResponse.error.includes("trying to get non-existing value for contract instance");
29498
29365
  // If the error message indicates that the user has no balance just return 0
29499
29366
  // We don't want to spam with this error as it's pretty common
29500
29367
  if (isNoBalanceError) {
@@ -29510,7 +29377,7 @@ class StellarRpcClient {
29510
29377
  }
29511
29378
  async getAllBalances(userAddress, tokens) {
29512
29379
  const balancePromises = tokens.map((token) => {
29513
- return this.getBalance(userAddress, token.chainAssetConfig.stellar.contractAddress, token.chainId);
29380
+ return this.getBalance(userAddress, token.address, token.chainId);
29514
29381
  });
29515
29382
  const results = await Promise.allSettled(balancePromises);
29516
29383
  const balances = results.map((result) => {
@@ -29610,9 +29477,9 @@ class XrplRpcClient {
29610
29477
  },
29611
29478
  ]);
29612
29479
  }
29613
- async getTrustLine(address, asset) {
29614
- const response = await this.getTrustLines(address, asset.issuer);
29615
- 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);
29616
29483
  return trustLine ?? null;
29617
29484
  }
29618
29485
  async accountActivatedInfo(address) {
@@ -29788,26 +29655,9 @@ class StellarApiClient {
29788
29655
  const baseReserveBn = BigInt(latestLedger.base_reserve_in_stroops);
29789
29656
  return baseReserveBn;
29790
29657
  }
29791
- async getTrustLines(userAddress) {
29792
- const response = await fetch(`${this.apiUrl}/accounts/${userAddress}`);
29793
- if (!response.ok) {
29794
- throw new Error(`Failed to fetch account data: ${response.statusText}`);
29795
- }
29796
- const data = await response.json();
29797
- if (!Array.isArray(data?.balances)) {
29798
- throw new Error("Invalid response from Horizon API");
29799
- }
29800
- const assets = data.balances.filter(isValidHorizonAsset);
29801
- return assets.filter(isValidIssuedAsset);
29802
- }
29803
- async getTrustLine(address, asset) {
29804
- const trustLines = await this.getTrustLines(address);
29805
- const trustLine = trustLines.find((line) => line.asset_code === asset.code && line.asset_issuer === asset.issuer);
29806
- return trustLine ?? null;
29807
- }
29808
29658
  }
29809
29659
 
29810
- const DEFAULT_REFETCH_INTERVAL$2 = 20_000;
29660
+ const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
29811
29661
  function useStellarAccountActivation({ address, chain, token, }) {
29812
29662
  /**
29813
29663
  * Checks if the destination account exists on the Stellar network
@@ -29823,8 +29673,9 @@ function useStellarAccountActivation({ address, chain, token, }) {
29823
29673
  if (!address) {
29824
29674
  throw new Error("Destination address is required");
29825
29675
  }
29826
- const horizonApiUrl = getStellarHorizonApiUrl(chain);
29827
- if (!horizonApiUrl) {
29676
+ // TODO: update types
29677
+ const [horizonApiUrl] = chain?.horizonRpcList;
29678
+ if (typeof horizonApiUrl !== "string") {
29828
29679
  throw new Error("Invalid Horizon API URL");
29829
29680
  }
29830
29681
  const stellarApiClient = new StellarApiClient(horizonApiUrl);
@@ -29840,7 +29691,7 @@ function useStellarAccountActivation({ address, chain, token, }) {
29840
29691
  };
29841
29692
  },
29842
29693
  enabled: !!address && chain?.chainType === squidTypes.ChainType.STELLAR,
29843
- refetchInterval: DEFAULT_REFETCH_INTERVAL$2,
29694
+ refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
29844
29695
  refetchOnWindowFocus: true,
29845
29696
  });
29846
29697
  return {
@@ -29848,149 +29699,6 @@ function useStellarAccountActivation({ address, chain, token, }) {
29848
29699
  };
29849
29700
  }
29850
29701
 
29851
- /**
29852
- * Maximum asset amount on Stellar
29853
- * @see https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/assets#amount-precision
29854
- */
29855
- const MAX_ASSET_AMOUNT = "922337203685.4775807";
29856
- const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
29857
- function useStellarTrustLine({ address, chain, token, amount }) {
29858
- const { stellarSigner } = useSigner({ chain });
29859
- const queryClient = reactQuery.useQueryClient();
29860
- /**
29861
- * Retrieves the destination account's trust line data for the given token
29862
- */
29863
- const trustLineQuery = reactQuery.useQuery({
29864
- queryKey: keys().stellarTrustLine(token?.address, chain?.chainId, address),
29865
- queryFn: async () => {
29866
- if (chain?.chainType !== squidTypes.ChainType.STELLAR ||
29867
- token?.type !== squidTypes.ChainType.STELLAR) {
29868
- return null;
29869
- }
29870
- if (!address || !isStellarAddressValid(address)) {
29871
- return null;
29872
- }
29873
- // Only issued tokens require trust lines
29874
- // Other token types like contract tokens don't need trust lines
29875
- if (!isStellarIssuedToken(token)) {
29876
- return null;
29877
- }
29878
- const asset = getStellarTrustLineAsset(token);
29879
- if (!asset) {
29880
- throw new Error("Invalid asset");
29881
- }
29882
- const horizonApiUrl = getStellarHorizonApiUrl(chain);
29883
- if (!horizonApiUrl) {
29884
- throw new Error("Invalid Horizon API URL");
29885
- }
29886
- const stellarApiClient = new StellarApiClient(horizonApiUrl);
29887
- return stellarApiClient.getTrustLine(address, asset);
29888
- },
29889
- enabled: !!address &&
29890
- chain?.chainType === squidTypes.ChainType.STELLAR &&
29891
- token?.type === squidTypes.ChainType.STELLAR,
29892
- refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
29893
- });
29894
- /**
29895
- * Creates a trust line where the destination account authorizes to receive the given token
29896
- */
29897
- const createTrustLine = reactQuery.useMutation({
29898
- mutationFn: async () => {
29899
- try {
29900
- if (!stellarSigner) {
29901
- throw new Error("Stellar signer not found");
29902
- }
29903
- if (!address) {
29904
- throw new Error("Destination address is required");
29905
- }
29906
- if (chain?.chainType !== squidTypes.ChainType.STELLAR ||
29907
- token?.type !== squidTypes.ChainType.STELLAR) {
29908
- throw new Error("Chain and token to approve must be a Stellar token");
29909
- }
29910
- if (!isStellarIssuedToken(token)) {
29911
- throw new Error("Token must be a Stellar issued token");
29912
- }
29913
- const assetInfo = getStellarTrustLineAsset(token);
29914
- if (!assetInfo) {
29915
- throw new Error("Invalid asset");
29916
- }
29917
- const network = getStellarNetwork(chain.chainId);
29918
- if (network == null) {
29919
- throw new Error(`Stellar network not found for chain ${chain.chainId}`);
29920
- }
29921
- const client = await getClient(chain);
29922
- const account = await client.getAccount(address);
29923
- const asset = new stellarSdk.Asset(assetInfo.code, assetInfo.issuer);
29924
- const changeTrustOperation = stellarSdk.Operation.changeTrust({
29925
- asset,
29926
- limit: MAX_ASSET_AMOUNT,
29927
- });
29928
- const builtTransaction = new stellarSdk.TransactionBuilder(account, {
29929
- fee: (BigInt(stellarSdk.BASE_FEE) * BigInt(2)).toString(),
29930
- networkPassphrase: network,
29931
- })
29932
- .addOperation(changeTrustOperation)
29933
- .setTimeout(300)
29934
- .build();
29935
- const { signedTxXdr } = await stellarSigner.signTransaction(builtTransaction.toXDR(), {
29936
- networkPassphrase: network,
29937
- });
29938
- const signedTransaction = new stellarSdk.Transaction(signedTxXdr, network);
29939
- const sentTransaction = await client.sendTransaction(signedTransaction);
29940
- const txStatus = await client.waitForTransaction(sentTransaction.hash, {
29941
- interval: 1_000,
29942
- });
29943
- if (txStatus !== stellarSdk.rpc.Api.GetTransactionStatus.SUCCESS) {
29944
- throw new Error(`Transaction failed with status: ${txStatus}`);
29945
- }
29946
- return true;
29947
- }
29948
- catch (error) {
29949
- console.error("Error creating trust line:", error);
29950
- return false;
29951
- }
29952
- },
29953
- async onSuccess() {
29954
- queryClient.invalidateQueries({
29955
- queryKey: getPrefixKey(exports.QueryKeys.StellarTrustLine),
29956
- });
29957
- },
29958
- });
29959
- /**
29960
- * Checks if the destination account has created a trust line to receive the given token.
29961
- */
29962
- const isTrustLineApproved = reactQuery.useQuery({
29963
- queryKey: keys().isStellarTrustLineApproved(address, token?.chainId, token?.type, token?.address, trustLineQuery.data?.limit, amount),
29964
- queryFn: async () => {
29965
- if (token?.type !== squidTypes.ChainType.STELLAR) {
29966
- return true;
29967
- }
29968
- // The native Stellar token doesn't need a trust line
29969
- if (token.address.toLowerCase() === nativeStellarTokenAddress.toLowerCase()) {
29970
- return true;
29971
- }
29972
- if (!amount) {
29973
- throw new Error("Amount is required");
29974
- }
29975
- const limitBn = BigNumber(trustLineQuery.data?.limit || "0");
29976
- const balanceBn = BigNumber(trustLineQuery.data?.balance || "0");
29977
- const availableAllowanceBn = limitBn.minus(balanceBn);
29978
- const amountBn = BigNumber(formatBNToReadable(amount, token.decimals));
29979
- return availableAllowanceBn.gte(amountBn);
29980
- },
29981
- enabled: !!address &&
29982
- !!amount &&
29983
- !trustLineQuery?.isLoading &&
29984
- trustLineQuery?.isFetched &&
29985
- token?.type === squidTypes.ChainType.STELLAR,
29986
- });
29987
- return {
29988
- createTrustLine,
29989
- trustLineQuery,
29990
- isTrustLineApproved,
29991
- };
29992
- }
29993
-
29994
29702
  const useAddressBookStore = zustand.create(middleware.persist((set) => ({
29995
29703
  addressBook: [],
29996
29704
  add: (newAddressData) => {
@@ -31613,18 +31321,15 @@ async function sendTransactionXrpl({ amount, signer, to, token, from, }) {
31613
31321
  txHash: hash,
31614
31322
  };
31615
31323
  }
31616
- const asset = parseXrplTokenAddress(token.address);
31617
- if (!asset) {
31618
- throw new Error("Invalid asset");
31619
- }
31324
+ const [currency, issuer] = token.address.split(".");
31620
31325
  const amountFormatted = formatBNToReadable(amount, token.decimals);
31621
31326
  const { hash } = await signer.signAndSubmit({
31622
31327
  network: xrplNetwork,
31623
31328
  tx: {
31624
31329
  ...baseTransaction,
31625
31330
  Amount: {
31626
- currency: asset.code,
31627
- issuer: asset.issuer,
31331
+ currency,
31332
+ issuer,
31628
31333
  value: amountFormatted,
31629
31334
  },
31630
31335
  },
@@ -32357,7 +32062,7 @@ const useApproval = ({ squidRoute, }) => {
32357
32062
  * On Error: Showing the error message if any
32358
32063
  * @returns {boolean} approved
32359
32064
  */
32360
- const routeApproved = reactQuery.useQuery(keys().routeApproved(squidRoute, allowanceInWei, erc20AllowanceQueryEnabled, hasAllowance), async () => {
32065
+ const routeApproved = reactQuery.useQuery(keys().routeApproved(squidRoute, allowanceInWei), async () => {
32361
32066
  if (erc20AllowanceQueryEnabled) {
32362
32067
  return hasAllowance;
32363
32068
  }
@@ -36865,12 +36570,12 @@ function useXrplTrustLine({ address, chain, token, amount }) {
36865
36570
  if (!address || !isXrplAddressValid(address)) {
36866
36571
  return null;
36867
36572
  }
36868
- const trustLineAsset = parseXrplTokenAddress(token.address);
36869
- if (!trustLineAsset) {
36573
+ const [currency, issuer] = token.address.split(".");
36574
+ if (!currency || !issuer) {
36870
36575
  return null;
36871
36576
  }
36872
36577
  const xrplClient = await getClient(chain);
36873
- const trustLine = await xrplClient.getTrustLine(address, trustLineAsset);
36578
+ const trustLine = await xrplClient.getTrustLine(address, issuer, currency);
36874
36579
  return trustLine;
36875
36580
  },
36876
36581
  enabled: !!address &&
@@ -37196,9 +36901,6 @@ exports.getSecretNetworkBalances = getSecretNetworkBalances;
37196
36901
  exports.getSendTxStatusRefetchInterval = getSendTxStatusRefetchInterval;
37197
36902
  exports.getSourceExplorerTxUrl = getSourceExplorerTxUrl;
37198
36903
  exports.getStatusCode = getStatusCode;
37199
- exports.getStellarHorizonApiUrl = getStellarHorizonApiUrl;
37200
- exports.getStellarNetwork = getStellarNetwork;
37201
- exports.getStellarTrustLineAsset = getStellarTrustLineAsset;
37202
36904
  exports.getStepStatuses = getStepStatuses;
37203
36905
  exports.getStepsInfos = getStepsInfos;
37204
36906
  exports.getSuggestedAmountsForCurrency = getSuggestedAmountsForCurrency;
@@ -37234,13 +36936,8 @@ exports.isHistoryTransactionWarning = isHistoryTransactionWarning;
37234
36936
  exports.isProblematicConnector = isProblematicConnector;
37235
36937
  exports.isSolanaAddressValid = isSolanaAddressValid;
37236
36938
  exports.isStatusError = isStatusError;
37237
- exports.isStellarAddressValid = isStellarAddressValid;
37238
- exports.isStellarIssuedToken = isStellarIssuedToken;
37239
- exports.isStellarToken = isStellarToken;
37240
36939
  exports.isSwapRouteError = isSwapRouteError;
37241
36940
  exports.isUserRejectionError = isUserRejectionError;
37242
- exports.isValidHorizonAsset = isValidHorizonAsset;
37243
- exports.isValidIssuedAsset = isValidIssuedAsset;
37244
36941
  exports.isWalletAddressValid = isWalletAddressValid;
37245
36942
  exports.isXamanXAppContext = isXamanXAppContext;
37246
36943
  exports.isXionSmartContractAddress = isXionSmartContractAddress;
@@ -37259,7 +36956,6 @@ exports.normalizeTokenSymbol = normalizeTokenSymbol;
37259
36956
  exports.parseEvmAddress = parseEvmAddress;
37260
36957
  exports.parseToBigInt = parseToBigInt;
37261
36958
  exports.parseXrplPaymentTx = parseXrplPaymentTx;
37262
- exports.parseXrplTokenAddress = parseXrplTokenAddress;
37263
36959
  exports.populateWallets = populateWallets;
37264
36960
  exports.randomIntFromInterval = randomIntFromInterval;
37265
36961
  exports.redirectToExtensionsStore = redirectToExtensionsStore;
@@ -37272,7 +36968,6 @@ exports.sortAddressBook = sortAddressBook;
37272
36968
  exports.sortAllTokens = sortAllTokens;
37273
36969
  exports.sortTokensBySharedSubgraphIds = sortTokensBySharedSubgraphIds;
37274
36970
  exports.sortWallets = sortWallets;
37275
- exports.stellarAddressToScVal = stellarAddressToScVal;
37276
36971
  exports.suggestChainOrThrow = suggestChainOrThrow;
37277
36972
  exports.transactionErrorCode = transactionErrorCode;
37278
36973
  exports.trimExtraDecimals = trimExtraDecimals;
@@ -37338,7 +37033,6 @@ exports.useSquidQueryClient = useSquidQueryClient;
37338
37033
  exports.useSquidStore = useSquidStore;
37339
37034
  exports.useSquidTokens = useSquidTokens;
37340
37035
  exports.useStellarAccountActivation = useStellarAccountActivation;
37341
- exports.useStellarTrustLine = useStellarTrustLine;
37342
37036
  exports.useSuggestedFiatAmounts = useSuggestedFiatAmounts;
37343
37037
  exports.useSwap = useSwap;
37344
37038
  exports.useSwapRoutePersistStore = useSwapRoutePersistStore;
@@ -37354,4 +37048,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
37354
37048
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
37355
37049
  exports.walletIconBaseUrl = walletIconBaseUrl;
37356
37050
  exports.walletSupportsChainType = walletSupportsChainType;
37357
- //# sourceMappingURL=index-CJQHDfLM.js.map
37051
+ //# sourceMappingURL=index-qAOvcSon.js.map