@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.
- package/dist/core/queries/queries-keys.d.ts +0 -4
- package/dist/core/types/index.d.ts +1 -1
- package/dist/core/types/stellar.d.ts +0 -26
- package/dist/core/types/tokens.d.ts +0 -4
- package/dist/hooks/index.d.ts +0 -1
- package/dist/{index-kjGUz03c.js → index-CMrdTYeW.js} +20 -232
- package/dist/index-CMrdTYeW.js.map +1 -0
- package/dist/{index-BXgsQg3P.js → index-qAOvcSon.js} +18 -236
- package/dist/index-qAOvcSon.js.map +1 -0
- package/dist/{index.es-GXiTUtqs.js → index.es-Cu_QQTg-.js} +2 -2
- package/dist/{index.es-GXiTUtqs.js.map → index.es-Cu_QQTg-.js.map} +1 -1
- package/dist/{index.es-ZxzIbkdb.js → index.es-DRgOycmm.js} +2 -2
- package/dist/{index.es-ZxzIbkdb.js.map → index.es-DRgOycmm.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -7
- package/dist/index.js.map +1 -1
- package/dist/{secretService-X5xnwohc.js → secretService-B3sc6ibT.js} +2 -2
- package/dist/{secretService-X5xnwohc.js.map → secretService-B3sc6ibT.js.map} +1 -1
- package/dist/{secretService-BySTXkzG.js → secretService-B_-XWo1F.js} +2 -2
- package/dist/{secretService-BySTXkzG.js.map → secretService-B_-XWo1F.js.map} +1 -1
- package/dist/services/external/stellarApiClient.d.ts +0 -4
- package/dist/services/external/xrplRpcClient.d.ts +1 -2
- package/dist/services/index.d.ts +0 -1
- package/dist/services/internal/stellarService.d.ts +0 -2
- package/dist/services/internal/xrplService.d.ts +0 -2
- package/dist/{stellarService.client-hm8DCtO1.js → stellarService.client-Ciqw9lmL.js} +2 -2
- package/dist/{stellarService.client-hm8DCtO1.js.map → stellarService.client-Ciqw9lmL.js.map} +1 -1
- package/dist/{stellarService.client-T2DBSYr3.js → stellarService.client-sRzC5VSD.js} +2 -2
- package/dist/{stellarService.client-T2DBSYr3.js.map → stellarService.client-sRzC5VSD.js.map} +1 -1
- package/package.json +3 -3
- package/dist/hooks/stellar/useStellarTrustLine.d.ts +0 -13
- package/dist/index-BXgsQg3P.js.map +0 -1
- package/dist/index-kjGUz03c.js.map +0 -1
|
@@ -34,8 +34,6 @@ export declare enum QueryKeys {
|
|
|
34
34
|
XrplAccountActivatedInfo = "xrplAccountActivatedInfo",
|
|
35
35
|
FiatToCryptoPaymentMethods = "fiatToCryptoPaymentMethods",
|
|
36
36
|
Stellar = "stellar",
|
|
37
|
-
StellarTrustLine = "stellarTrustLine",
|
|
38
|
-
IsStellarTrustLineApproved = "isStellarTrustLineApproved",
|
|
39
37
|
StellarAccountActivatedInfo = "stellarAccountActivatedInfo",
|
|
40
38
|
Hedera = "hedera",
|
|
41
39
|
IsHederaTokenAssociated = "isHederaTokenAssociated"
|
|
@@ -73,8 +71,6 @@ export declare const keys: () => {
|
|
|
73
71
|
xrplTrustLine: (tokenAddress: string | undefined, chainId: string | undefined, address: string | undefined) => (string | undefined)[];
|
|
74
72
|
isXrplTrustLineApproved: (address: string | undefined, chainId: string | undefined, chainType: ChainType | undefined, tokenAddress: string | undefined, trustLineLimit: string | undefined, amountToApprove: bigint | undefined) => (string | undefined)[];
|
|
75
73
|
xrplAccountActivatedInfo: (destinationAddress: string | undefined, toChainId: string | undefined, toChainType: ChainType | undefined) => (string | undefined)[];
|
|
76
|
-
stellarTrustLine: (tokenAddress: string | undefined, chainId: string | undefined, address: string | undefined) => (string | undefined)[];
|
|
77
|
-
isStellarTrustLineApproved: (address: string | undefined, chainId: string | undefined, chainType: ChainType | undefined, tokenAddress: string | undefined, trustLineLimit: string | undefined, amountToApprove: bigint | undefined) => (string | undefined)[];
|
|
78
74
|
stellarAccountActivatedInfo: (address: string | undefined, chainId: string | undefined, chainType: ChainType | undefined) => (string | undefined)[];
|
|
79
75
|
isHederaTokenAssociated: (address: string | undefined, chainId: string | undefined, chainType: ChainType | undefined, tokenAddress: string | undefined) => (string | undefined)[];
|
|
80
76
|
};
|
|
@@ -4,7 +4,7 @@ export type { QrCodeData } from "./event";
|
|
|
4
4
|
export * from "./history";
|
|
5
5
|
export type * from "./onramps/";
|
|
6
6
|
export type { SwapParams } from "./swap";
|
|
7
|
-
export type { Chain, Token
|
|
7
|
+
export type { Chain, Token } from "./tokens";
|
|
8
8
|
export { AxelarStatusResponseType, SendTransactionStatus, TransactionStatus, type PatchedRouteActionResponse, type TransactionParams, } from "./transaction";
|
|
9
9
|
export type { AddressWithEns, BitcoinWallet, ConnectorID, CosmosWallet, EnsData, EnsSearchResult, FullAddressData, NetworkConfig, SolanaWallet, SupportedChain, Wallet, } from "./wallet";
|
|
10
10
|
export { XamanXrplNetwork } from "./xrpl";
|
|
@@ -1,29 +1,3 @@
|
|
|
1
1
|
import type { ModuleInterface } from "@creit.tech/stellar-wallets-kit";
|
|
2
2
|
export interface StellarConnector extends ModuleInterface {
|
|
3
3
|
}
|
|
4
|
-
export declare enum StellarAssetType {
|
|
5
|
-
/**
|
|
6
|
-
* XLM native token
|
|
7
|
-
*/
|
|
8
|
-
NATIVE = "native",
|
|
9
|
-
/**
|
|
10
|
-
* 1-4 char asset code (e.g. USDC)
|
|
11
|
-
*/
|
|
12
|
-
ALPHANUM4 = "alphanum4",
|
|
13
|
-
/**
|
|
14
|
-
* 5-12 char asset code (e.g. wstETH)
|
|
15
|
-
*/
|
|
16
|
-
ALPHANUM12 = "alphanum12"
|
|
17
|
-
}
|
|
18
|
-
export interface StellarNativeAsset {
|
|
19
|
-
balance: string;
|
|
20
|
-
asset_type: StellarAssetType.NATIVE;
|
|
21
|
-
}
|
|
22
|
-
export interface StellarIssuedAsset {
|
|
23
|
-
balance: string;
|
|
24
|
-
asset_type: Exclude<StellarAssetType, StellarAssetType.NATIVE>;
|
|
25
|
-
asset_code: string;
|
|
26
|
-
asset_issuer: string;
|
|
27
|
-
limit: string;
|
|
28
|
-
}
|
|
29
|
-
export type StellarTrustLine = StellarIssuedAsset;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from "./onramp/useFiatToCrypto";
|
|
|
8
8
|
export { useSquidQueryClient } from "./query/useSquidQueryClient";
|
|
9
9
|
export { useSquid } from "./squid/useSquid";
|
|
10
10
|
export { useStellarAccountActivation } from "./stellar/useStellarAccountActivation";
|
|
11
|
-
export { useStellarTrustLine } from "./stellar/useStellarTrustLine";
|
|
12
11
|
export { useAddressBookStore } from "./store/useAddressBookStore";
|
|
13
12
|
export { useAssetsColorsStore } from "./store/useAssetsColorsStore";
|
|
14
13
|
export { useFavoriteTokensStore, type FavoriteToken, } from "./store/useFavoriteTokensStore";
|
|
@@ -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 {
|
|
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
|
|
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
|
|
20109
|
-
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 {
|
|
@@ -21131,16 +21118,6 @@ function stellarAddressToScVal(addressString) {
|
|
|
21131
21118
|
type: "address",
|
|
21132
21119
|
});
|
|
21133
21120
|
}
|
|
21134
|
-
function parseStellarAssetId(assetId) {
|
|
21135
|
-
const [code, issuer] = assetId.split("-");
|
|
21136
|
-
if (!code || !issuer) {
|
|
21137
|
-
return null;
|
|
21138
|
-
}
|
|
21139
|
-
return {
|
|
21140
|
-
code,
|
|
21141
|
-
issuer,
|
|
21142
|
-
};
|
|
21143
|
-
}
|
|
21144
21121
|
|
|
21145
21122
|
const SUI_FEATURES = ["sui:signTransaction"];
|
|
21146
21123
|
function isSuiStandardWallet(wallet) {
|
|
@@ -22219,8 +22196,6 @@ var QueryKeys;
|
|
|
22219
22196
|
QueryKeys["XrplAccountActivatedInfo"] = "xrplAccountActivatedInfo";
|
|
22220
22197
|
QueryKeys["FiatToCryptoPaymentMethods"] = "fiatToCryptoPaymentMethods";
|
|
22221
22198
|
QueryKeys["Stellar"] = "stellar";
|
|
22222
|
-
QueryKeys["StellarTrustLine"] = "stellarTrustLine";
|
|
22223
|
-
QueryKeys["IsStellarTrustLineApproved"] = "isStellarTrustLineApproved";
|
|
22224
22199
|
QueryKeys["StellarAccountActivatedInfo"] = "stellarAccountActivatedInfo";
|
|
22225
22200
|
QueryKeys["Hedera"] = "hedera";
|
|
22226
22201
|
QueryKeys["IsHederaTokenAssociated"] = "isHederaTokenAssociated";
|
|
@@ -22408,23 +22383,6 @@ const keys = () => ({
|
|
|
22408
22383
|
// ============
|
|
22409
22384
|
// Stellar
|
|
22410
22385
|
// ============
|
|
22411
|
-
stellarTrustLine: (tokenAddress, chainId, address) => [
|
|
22412
|
-
...keys().stellar(),
|
|
22413
|
-
QueryKeys.StellarTrustLine,
|
|
22414
|
-
tokenAddress,
|
|
22415
|
-
chainId,
|
|
22416
|
-
address,
|
|
22417
|
-
],
|
|
22418
|
-
isStellarTrustLineApproved: (address, chainId, chainType, tokenAddress, trustLineLimit, amountToApprove) => [
|
|
22419
|
-
...keys().stellar(),
|
|
22420
|
-
QueryKeys.IsStellarTrustLineApproved,
|
|
22421
|
-
address,
|
|
22422
|
-
chainId,
|
|
22423
|
-
chainType,
|
|
22424
|
-
tokenAddress,
|
|
22425
|
-
trustLineLimit,
|
|
22426
|
-
amountToApprove?.toString(),
|
|
22427
|
-
],
|
|
22428
22386
|
stellarAccountActivatedInfo: (address, chainId, chainType) => [
|
|
22429
22387
|
...keys().stellar(),
|
|
22430
22388
|
QueryKeys.StellarAccountActivatedInfo,
|
|
@@ -23174,7 +23132,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23174
23132
|
};
|
|
23175
23133
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23176
23134
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23177
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23135
|
+
const { fetchAllSecretBalances } = await import('./secretService-B3sc6ibT.js');
|
|
23178
23136
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23179
23137
|
};
|
|
23180
23138
|
function getTokenAssetsKey(token) {
|
|
@@ -26459,7 +26417,7 @@ function useStellarWallets() {
|
|
|
26459
26417
|
try {
|
|
26460
26418
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26461
26419
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26462
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26420
|
+
const { formatStellarWallet } = await import('./stellarService.client-Ciqw9lmL.js');
|
|
26463
26421
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26464
26422
|
const promises = modules.map(async (module) => {
|
|
26465
26423
|
const isAvailable = await module.isAvailable();
|
|
@@ -27959,7 +27917,7 @@ function hederaWalletConnect(parameters) {
|
|
|
27959
27917
|
const optionalChains = config.chains.map((x) => x.id);
|
|
27960
27918
|
if (!optionalChains.length)
|
|
27961
27919
|
return;
|
|
27962
|
-
const { EthereumProvider } = await import('./index.es-
|
|
27920
|
+
const { EthereumProvider } = await import('./index.es-DRgOycmm.js');
|
|
27963
27921
|
const rawProvider = await EthereumProvider.init({
|
|
27964
27922
|
...restParameters,
|
|
27965
27923
|
disableProviderPing: true,
|
|
@@ -29498,9 +29456,9 @@ class XrplRpcClient {
|
|
|
29498
29456
|
},
|
|
29499
29457
|
]);
|
|
29500
29458
|
}
|
|
29501
|
-
async getTrustLine(address,
|
|
29502
|
-
const response = await this.getTrustLines(address,
|
|
29503
|
-
const trustLine = response.lines.find((line) => line.currency ===
|
|
29459
|
+
async getTrustLine(address, issuer, currency) {
|
|
29460
|
+
const response = await this.getTrustLines(address, issuer);
|
|
29461
|
+
const trustLine = response.lines.find((line) => line.currency === currency);
|
|
29504
29462
|
return trustLine ?? null;
|
|
29505
29463
|
}
|
|
29506
29464
|
async accountActivatedInfo(address) {
|
|
@@ -29658,22 +29616,6 @@ async function createClient(chain) {
|
|
|
29658
29616
|
}
|
|
29659
29617
|
}
|
|
29660
29618
|
|
|
29661
|
-
var StellarAssetType;
|
|
29662
|
-
(function (StellarAssetType) {
|
|
29663
|
-
/**
|
|
29664
|
-
* XLM native token
|
|
29665
|
-
*/
|
|
29666
|
-
StellarAssetType["NATIVE"] = "native";
|
|
29667
|
-
/**
|
|
29668
|
-
* 1-4 char asset code (e.g. USDC)
|
|
29669
|
-
*/
|
|
29670
|
-
StellarAssetType["ALPHANUM4"] = "alphanum4";
|
|
29671
|
-
/**
|
|
29672
|
-
* 5-12 char asset code (e.g. wstETH)
|
|
29673
|
-
*/
|
|
29674
|
-
StellarAssetType["ALPHANUM12"] = "alphanum12";
|
|
29675
|
-
})(StellarAssetType || (StellarAssetType = {}));
|
|
29676
|
-
|
|
29677
29619
|
class StellarApiClient {
|
|
29678
29620
|
apiUrl;
|
|
29679
29621
|
constructor(apiUrl) {
|
|
@@ -29692,26 +29634,9 @@ class StellarApiClient {
|
|
|
29692
29634
|
const baseReserveBn = BigInt(latestLedger.base_reserve_in_stroops);
|
|
29693
29635
|
return baseReserveBn;
|
|
29694
29636
|
}
|
|
29695
|
-
async getTrustLines(userAddress) {
|
|
29696
|
-
const response = await fetch(`${this.apiUrl}/accounts/${userAddress}`);
|
|
29697
|
-
if (!response.ok) {
|
|
29698
|
-
throw new Error(`Failed to fetch account data: ${response.statusText}`);
|
|
29699
|
-
}
|
|
29700
|
-
const data = await response.json();
|
|
29701
|
-
if (!Array.isArray(data?.balances)) {
|
|
29702
|
-
throw new Error("Invalid response from Horizon API");
|
|
29703
|
-
}
|
|
29704
|
-
const assets = data.balances;
|
|
29705
|
-
return assets.filter((asset) => asset.asset_type !== StellarAssetType.NATIVE);
|
|
29706
|
-
}
|
|
29707
|
-
async getTrustLine(address, asset) {
|
|
29708
|
-
const trustLines = await this.getTrustLines(address);
|
|
29709
|
-
const trustLine = trustLines.find((line) => line.asset_code === asset.code && line.asset_issuer === asset.issuer);
|
|
29710
|
-
return trustLine ?? null;
|
|
29711
|
-
}
|
|
29712
29637
|
}
|
|
29713
29638
|
|
|
29714
|
-
const DEFAULT_REFETCH_INTERVAL$
|
|
29639
|
+
const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
|
|
29715
29640
|
function useStellarAccountActivation({ address, chain, token, }) {
|
|
29716
29641
|
/**
|
|
29717
29642
|
* Checks if the destination account exists on the Stellar network
|
|
@@ -29745,7 +29670,7 @@ function useStellarAccountActivation({ address, chain, token, }) {
|
|
|
29745
29670
|
};
|
|
29746
29671
|
},
|
|
29747
29672
|
enabled: !!address && chain?.chainType === ChainType.STELLAR,
|
|
29748
|
-
refetchInterval: DEFAULT_REFETCH_INTERVAL$
|
|
29673
|
+
refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
|
|
29749
29674
|
refetchOnWindowFocus: true,
|
|
29750
29675
|
});
|
|
29751
29676
|
return {
|
|
@@ -29753,140 +29678,6 @@ function useStellarAccountActivation({ address, chain, token, }) {
|
|
|
29753
29678
|
};
|
|
29754
29679
|
}
|
|
29755
29680
|
|
|
29756
|
-
/**
|
|
29757
|
-
* Maximum asset amount on Stellar
|
|
29758
|
-
* @see https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/assets#amount-precision
|
|
29759
|
-
*/
|
|
29760
|
-
const MAX_ASSET_AMOUNT = "922337203685.4775807";
|
|
29761
|
-
const DEFAULT_REFETCH_INTERVAL$1 = 20_000;
|
|
29762
|
-
function useStellarTrustLine({ address, chain, token, amount }) {
|
|
29763
|
-
const { stellarSigner } = useSigner({ chain });
|
|
29764
|
-
const queryClient = useQueryClient();
|
|
29765
|
-
/**
|
|
29766
|
-
* Retrieves the destination account's trust line data for the given token
|
|
29767
|
-
*/
|
|
29768
|
-
const trustLineQuery = useQuery({
|
|
29769
|
-
queryKey: keys().stellarTrustLine(token?.address, chain?.chainId, address),
|
|
29770
|
-
queryFn: async () => {
|
|
29771
|
-
if (chain?.chainType !== ChainType.STELLAR ||
|
|
29772
|
-
token?.type !== ChainType.STELLAR) {
|
|
29773
|
-
return null;
|
|
29774
|
-
}
|
|
29775
|
-
if (!address || !isStellarAddressValid(address)) {
|
|
29776
|
-
return null;
|
|
29777
|
-
}
|
|
29778
|
-
const asset = parseStellarAssetId(token?.assetId);
|
|
29779
|
-
if (!asset) {
|
|
29780
|
-
return null;
|
|
29781
|
-
}
|
|
29782
|
-
// TODO: update types
|
|
29783
|
-
const [horizonApiUrl] = chain?.horizonRpcList;
|
|
29784
|
-
if (typeof horizonApiUrl !== "string") {
|
|
29785
|
-
throw new Error("Invalid Horizon API URL");
|
|
29786
|
-
}
|
|
29787
|
-
const stellarApiClient = new StellarApiClient(horizonApiUrl);
|
|
29788
|
-
const trustLine = await stellarApiClient.getTrustLine(address, asset);
|
|
29789
|
-
return trustLine;
|
|
29790
|
-
},
|
|
29791
|
-
enabled: !!address &&
|
|
29792
|
-
chain?.chainType === ChainType.STELLAR &&
|
|
29793
|
-
token?.type === ChainType.STELLAR,
|
|
29794
|
-
refetchInterval: DEFAULT_REFETCH_INTERVAL$1,
|
|
29795
|
-
});
|
|
29796
|
-
/**
|
|
29797
|
-
* Creates a trust line where the destination account authorizes to receive the given token
|
|
29798
|
-
*/
|
|
29799
|
-
const createTrustLine = useMutation({
|
|
29800
|
-
mutationFn: async () => {
|
|
29801
|
-
try {
|
|
29802
|
-
if (!stellarSigner) {
|
|
29803
|
-
throw new Error("Stellar signer not found");
|
|
29804
|
-
}
|
|
29805
|
-
if (!address) {
|
|
29806
|
-
throw new Error("Destination address is required");
|
|
29807
|
-
}
|
|
29808
|
-
if (chain?.chainType !== ChainType.STELLAR ||
|
|
29809
|
-
token?.type !== ChainType.STELLAR) {
|
|
29810
|
-
throw new Error("Chain and token to approve must be a Stellar token");
|
|
29811
|
-
}
|
|
29812
|
-
const assetInfo = parseStellarAssetId(token?.assetId);
|
|
29813
|
-
if (!assetInfo) {
|
|
29814
|
-
throw new Error("Invalid asset");
|
|
29815
|
-
}
|
|
29816
|
-
const network = getStellarNetwork(chain.chainId);
|
|
29817
|
-
if (network == null) {
|
|
29818
|
-
throw new Error(`Stellar network not found for chain ${chain.chainId}`);
|
|
29819
|
-
}
|
|
29820
|
-
const client = await getClient(chain);
|
|
29821
|
-
const account = await client.getAccount(address);
|
|
29822
|
-
const asset = new Asset(assetInfo.code, assetInfo.issuer);
|
|
29823
|
-
const changeTrustOperation = Operation.changeTrust({
|
|
29824
|
-
asset,
|
|
29825
|
-
limit: MAX_ASSET_AMOUNT,
|
|
29826
|
-
});
|
|
29827
|
-
const builtTransaction = new TransactionBuilder(account, {
|
|
29828
|
-
fee: (BigInt(BASE_FEE) * BigInt(2)).toString(),
|
|
29829
|
-
networkPassphrase: network,
|
|
29830
|
-
})
|
|
29831
|
-
.addOperation(changeTrustOperation)
|
|
29832
|
-
.setTimeout(300)
|
|
29833
|
-
.build();
|
|
29834
|
-
const { signedTxXdr } = await stellarSigner.signTransaction(builtTransaction.toXDR(), {
|
|
29835
|
-
networkPassphrase: network,
|
|
29836
|
-
});
|
|
29837
|
-
const signedTransaction = new Transaction$1(signedTxXdr, network);
|
|
29838
|
-
const sentTransaction = await client.sendTransaction(signedTransaction);
|
|
29839
|
-
const txStatus = await client.waitForTransaction(sentTransaction.hash, {
|
|
29840
|
-
interval: 1_000,
|
|
29841
|
-
});
|
|
29842
|
-
if (txStatus !== rpc.Api.GetTransactionStatus.SUCCESS) {
|
|
29843
|
-
throw new Error(`Transaction failed with status: ${txStatus}`);
|
|
29844
|
-
}
|
|
29845
|
-
return true;
|
|
29846
|
-
}
|
|
29847
|
-
catch (error) {
|
|
29848
|
-
console.error("Error creating trust line:", error);
|
|
29849
|
-
return false;
|
|
29850
|
-
}
|
|
29851
|
-
},
|
|
29852
|
-
async onSuccess() {
|
|
29853
|
-
queryClient.invalidateQueries(getPrefixKey(QueryKeys.StellarTrustLine));
|
|
29854
|
-
},
|
|
29855
|
-
});
|
|
29856
|
-
/**
|
|
29857
|
-
* Checks if the destination account has created a trust line to receive the given token.
|
|
29858
|
-
*/
|
|
29859
|
-
const isTrustLineApproved = useQuery({
|
|
29860
|
-
queryKey: keys().isStellarTrustLineApproved(address, token?.chainId, token?.type, token?.address, trustLineQuery.data?.limit, amount),
|
|
29861
|
-
queryFn: async () => {
|
|
29862
|
-
if (token?.type !== ChainType.STELLAR) {
|
|
29863
|
-
return true;
|
|
29864
|
-
}
|
|
29865
|
-
// The native Stellar token doesn't need a trust line
|
|
29866
|
-
if (token.address.toLowerCase() === nativeStellarTokenAddress.toLowerCase()) {
|
|
29867
|
-
return true;
|
|
29868
|
-
}
|
|
29869
|
-
if (!amount) {
|
|
29870
|
-
throw new Error("Amount is required");
|
|
29871
|
-
}
|
|
29872
|
-
const limitBn = BigNumber$1(trustLineQuery.data?.limit || "0");
|
|
29873
|
-
const balanceBn = BigNumber$1(trustLineQuery.data?.balance || "0");
|
|
29874
|
-
const availableAllowanceBn = limitBn.minus(balanceBn);
|
|
29875
|
-
const amountBn = BigNumber$1(formatBNToReadable(amount, token.decimals));
|
|
29876
|
-
return availableAllowanceBn.gte(amountBn);
|
|
29877
|
-
},
|
|
29878
|
-
enabled: !!address &&
|
|
29879
|
-
!!amount &&
|
|
29880
|
-
trustLineQuery?.isSuccess &&
|
|
29881
|
-
token?.type === ChainType.STELLAR,
|
|
29882
|
-
});
|
|
29883
|
-
return {
|
|
29884
|
-
createTrustLine,
|
|
29885
|
-
trustLineQuery,
|
|
29886
|
-
isTrustLineApproved,
|
|
29887
|
-
};
|
|
29888
|
-
}
|
|
29889
|
-
|
|
29890
29681
|
const useAddressBookStore = create(persist((set) => ({
|
|
29891
29682
|
addressBook: [],
|
|
29892
29683
|
add: (newAddressData) => {
|
|
@@ -31509,18 +31300,15 @@ async function sendTransactionXrpl({ amount, signer, to, token, from, }) {
|
|
|
31509
31300
|
txHash: hash,
|
|
31510
31301
|
};
|
|
31511
31302
|
}
|
|
31512
|
-
const
|
|
31513
|
-
if (!asset) {
|
|
31514
|
-
throw new Error("Invalid asset");
|
|
31515
|
-
}
|
|
31303
|
+
const [currency, issuer] = token.address.split(".");
|
|
31516
31304
|
const amountFormatted = formatBNToReadable(amount, token.decimals);
|
|
31517
31305
|
const { hash } = await signer.signAndSubmit({
|
|
31518
31306
|
network: xrplNetwork,
|
|
31519
31307
|
tx: {
|
|
31520
31308
|
...baseTransaction,
|
|
31521
31309
|
Amount: {
|
|
31522
|
-
currency
|
|
31523
|
-
issuer
|
|
31310
|
+
currency,
|
|
31311
|
+
issuer,
|
|
31524
31312
|
value: amountFormatted,
|
|
31525
31313
|
},
|
|
31526
31314
|
},
|
|
@@ -36761,12 +36549,12 @@ function useXrplTrustLine({ address, chain, token, amount }) {
|
|
|
36761
36549
|
if (!address || !isXrplAddressValid(address)) {
|
|
36762
36550
|
return null;
|
|
36763
36551
|
}
|
|
36764
|
-
const
|
|
36765
|
-
if (!
|
|
36552
|
+
const [currency, issuer] = token.address.split(".");
|
|
36553
|
+
if (!currency || !issuer) {
|
|
36766
36554
|
return null;
|
|
36767
36555
|
}
|
|
36768
36556
|
const xrplClient = await getClient(chain);
|
|
36769
|
-
const trustLine = await xrplClient.getTrustLine(address,
|
|
36557
|
+
const trustLine = await xrplClient.getTrustLine(address, issuer, currency);
|
|
36770
36558
|
return trustLine;
|
|
36771
36559
|
},
|
|
36772
36560
|
enabled: !!address &&
|
|
@@ -37004,5 +36792,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37004
36792
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37005
36793
|
};
|
|
37006
36794
|
|
|
37007
|
-
export {
|
|
37008
|
-
//# sourceMappingURL=index-
|
|
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
|