@0xsquid/react-hooks 8.7.0 → 8.7.2-beta-bitcoin-solana-xrpl.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/connectors/bitcoin/wallets/keplr.d.ts +3 -0
- package/dist/core/connectors/bitcoin/wallets/phantom.d.ts +3 -1
- package/dist/core/connectors/bitcoin/wallets/unisat.d.ts +3 -0
- package/dist/core/types/bitcoin.d.ts +3 -0
- package/dist/core/types/history.d.ts +1 -1
- package/dist/hooks/transaction/useExecuteTransaction.d.ts +1 -1
- package/dist/{index-CpHc3uRR.js → index-BOXqAr2r.js} +195 -150
- package/dist/index-BOXqAr2r.js.map +1 -0
- package/dist/{index-BOMoTOCH.js → index-CpphPhUS.js} +194 -149
- package/dist/index-CpphPhUS.js.map +1 -0
- package/dist/{index.es-Bx1b09ob.js → index.es-BOb7ZHW7.js} +2 -2
- package/dist/{index.es-Bx1b09ob.js.map → index.es-BOb7ZHW7.js.map} +1 -1
- package/dist/{index.es-DYEb3pTJ.js → index.es-DBsq8Frv.js} +2 -2
- package/dist/{index.es-DYEb3pTJ.js.map → index.es-DBsq8Frv.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{secretService-0Y9Bj_Ic.js → secretService-DN6Mr9e8.js} +2 -2
- package/dist/{secretService-0Y9Bj_Ic.js.map → secretService-DN6Mr9e8.js.map} +1 -1
- package/dist/{secretService-DnKMq9Ib.js → secretService-Dg30HRy1.js} +2 -2
- package/dist/{secretService-DnKMq9Ib.js.map → secretService-Dg30HRy1.js.map} +1 -1
- package/dist/services/internal/solanaService.d.ts +16 -9
- package/dist/services/internal/transactionService.d.ts +1 -2
- package/dist/{stellarService.client-B3kAxROD.js → stellarService.client-B9bDVrW_.js} +2 -2
- package/dist/{stellarService.client-B3kAxROD.js.map → stellarService.client-B9bDVrW_.js.map} +1 -1
- package/dist/{stellarService.client-Dyichswq.js → stellarService.client-CybwDtEp.js} +2 -2
- package/dist/{stellarService.client-Dyichswq.js.map → stellarService.client-CybwDtEp.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BOMoTOCH.js.map +0 -1
- package/dist/index-CpHc3uRR.js.map +0 -1
|
@@ -4756,6 +4756,9 @@ class KeplrConnector {
|
|
|
4756
4756
|
address: account,
|
|
4757
4757
|
};
|
|
4758
4758
|
}
|
|
4759
|
+
async signPsbt(_) {
|
|
4760
|
+
throw new Error("Method not implemented.");
|
|
4761
|
+
}
|
|
4759
4762
|
}
|
|
4760
4763
|
|
|
4761
4764
|
bitcoin__namespace.initEccLib(ecc__namespace);
|
|
@@ -4870,10 +4873,8 @@ class PhantomConnector {
|
|
|
4870
4873
|
async sendBTC(to, amount) {
|
|
4871
4874
|
const { address } = await this.requestAccount();
|
|
4872
4875
|
const { psbtHex } = await createSendBtcPsbt(address, to, amount);
|
|
4873
|
-
const {
|
|
4874
|
-
|
|
4875
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
4876
|
-
return { txHash: txId };
|
|
4876
|
+
const { txHash } = await this.signPsbt(psbtHex);
|
|
4877
|
+
return { txHash };
|
|
4877
4878
|
}
|
|
4878
4879
|
async signPsbt(psbtHex) {
|
|
4879
4880
|
const { address: paymentAddress } = await this.requestAccount();
|
|
@@ -4894,8 +4895,10 @@ class PhantomConnector {
|
|
|
4894
4895
|
const signedPsbt = bitcoin__namespace.Psbt.fromBuffer(signedPsbtBytes);
|
|
4895
4896
|
signedPsbt.finalizeAllInputs();
|
|
4896
4897
|
const tx = signedPsbt.extractTransaction();
|
|
4897
|
-
const
|
|
4898
|
-
|
|
4898
|
+
const txHash = await broadcastTx(tx.toHex());
|
|
4899
|
+
if (!txHash)
|
|
4900
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4901
|
+
return { txHash };
|
|
4899
4902
|
}
|
|
4900
4903
|
}
|
|
4901
4904
|
|
|
@@ -4924,6 +4927,9 @@ class UnisatConnector {
|
|
|
4924
4927
|
address: account,
|
|
4925
4928
|
};
|
|
4926
4929
|
}
|
|
4930
|
+
async signPsbt(_) {
|
|
4931
|
+
throw new Error("Method not implemented.");
|
|
4932
|
+
}
|
|
4927
4933
|
}
|
|
4928
4934
|
|
|
4929
4935
|
var XrplTransactionType;
|
|
@@ -21074,6 +21080,7 @@ const formatSwapTxStatusResponseForStorage = (sr) => {
|
|
|
21074
21080
|
}
|
|
21075
21081
|
return {
|
|
21076
21082
|
axelarTransactionUrl: sr.axelarTransactionUrl,
|
|
21083
|
+
coralTransactionUrl: sr.coralTransactionUrl,
|
|
21077
21084
|
toChain: sr.toChain?.transactionUrl
|
|
21078
21085
|
? {
|
|
21079
21086
|
transactionUrl: sr.toChain?.transactionUrl,
|
|
@@ -21133,10 +21140,6 @@ function isCoralBridgeAction(action) {
|
|
|
21133
21140
|
function sleep(ms) {
|
|
21134
21141
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21135
21142
|
}
|
|
21136
|
-
const isDepositRoute = (route) => {
|
|
21137
|
-
return (!!route &&
|
|
21138
|
-
route.transactionRequest?.type === squidTypes.SquidDataType.ChainflipDepositAddress);
|
|
21139
|
-
};
|
|
21140
21143
|
/**
|
|
21141
21144
|
* Checks if the route contains a Chainflip bridge action
|
|
21142
21145
|
*/
|
|
@@ -21344,11 +21347,11 @@ const isSolanaAddressValid = (address) => {
|
|
|
21344
21347
|
* Execute a Solana swap transaction
|
|
21345
21348
|
* This will be used for the swap flow - Using Jupiter Dex under the hood
|
|
21346
21349
|
*/
|
|
21347
|
-
const executeSolanaSwap = async ({
|
|
21348
|
-
if (!
|
|
21349
|
-
throw new Error("Invalid
|
|
21350
|
+
const executeSolanaSwap = async ({ transactionRequest, signer, connection, }) => {
|
|
21351
|
+
if (!isOnChainTxData(transactionRequest)) {
|
|
21352
|
+
throw new Error("Invalid transaction request");
|
|
21350
21353
|
}
|
|
21351
|
-
const swapRequest =
|
|
21354
|
+
const swapRequest = transactionRequest.data;
|
|
21352
21355
|
const swapTransactionBuf = Buffer.from(swapRequest, "base64");
|
|
21353
21356
|
// TODO: fix types
|
|
21354
21357
|
// const transaction = VersionedTransaction.deserialize(
|
|
@@ -21356,15 +21359,9 @@ const executeSolanaSwap = async ({ route, signer, connection, onSigned, }) => {
|
|
|
21356
21359
|
// );
|
|
21357
21360
|
const transaction = web3_js.VersionedTransaction.deserialize(swapTransactionBuf);
|
|
21358
21361
|
try {
|
|
21359
|
-
const
|
|
21362
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
21360
21363
|
const signature = await signer.sendTransaction(transaction, connection);
|
|
21361
|
-
|
|
21362
|
-
await connection.confirmTransaction({
|
|
21363
|
-
signature,
|
|
21364
|
-
blockhash: latestBlockhash.blockhash,
|
|
21365
|
-
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
|
|
21366
|
-
});
|
|
21367
|
-
return signature;
|
|
21364
|
+
return { signature, blockhash, lastValidBlockHeight };
|
|
21368
21365
|
}
|
|
21369
21366
|
catch (error) {
|
|
21370
21367
|
console.error("Solana swap failed:", error);
|
|
@@ -21378,10 +21375,9 @@ const executeSolanaSwap = async ({ route, signer, connection, onSigned, }) => {
|
|
|
21378
21375
|
* @param signer - Solana wallet adapter instance
|
|
21379
21376
|
* @param connection - Solana RPC connection
|
|
21380
21377
|
* @param sourceToken - Token information (undefined for native SOL)
|
|
21381
|
-
* @param onSigned - Optional callback triggered when transaction is signed
|
|
21382
21378
|
* @returns Transaction signature
|
|
21383
21379
|
*/
|
|
21384
|
-
const executeSolanaTransfer = async ({ amount, target, signer, connection, sourceToken,
|
|
21380
|
+
const executeSolanaTransfer = async ({ amount, target, signer, connection, sourceToken, }) => {
|
|
21385
21381
|
// Validate signer and target address
|
|
21386
21382
|
if (!signer.publicKey) {
|
|
21387
21383
|
throw new Error("Signer public key not found");
|
|
@@ -21421,15 +21417,17 @@ const executeSolanaTransfer = async ({ amount, target, signer, connection, sourc
|
|
|
21421
21417
|
transaction.recentBlockhash = blockhash;
|
|
21422
21418
|
transaction.feePayer = signer.publicKey;
|
|
21423
21419
|
const signature = await signer.sendTransaction(transaction, connection);
|
|
21424
|
-
|
|
21425
|
-
|
|
21426
|
-
|
|
21427
|
-
|
|
21428
|
-
|
|
21429
|
-
|
|
21430
|
-
|
|
21431
|
-
});
|
|
21432
|
-
|
|
21420
|
+
return { signature, blockhash, lastValidBlockHeight };
|
|
21421
|
+
};
|
|
21422
|
+
const executeSolanaDepositAddressCalldata = async ({ transactionRequest, signer, connection, }) => {
|
|
21423
|
+
if (!isOnChainTxData(transactionRequest)) {
|
|
21424
|
+
throw new Error("Invalid transaction request");
|
|
21425
|
+
}
|
|
21426
|
+
const tx = web3_js.Transaction.from(Buffer.from(transactionRequest.data, "base64"));
|
|
21427
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
21428
|
+
tx.recentBlockhash = blockhash;
|
|
21429
|
+
const signature = await signer.sendTransaction(tx, connection);
|
|
21430
|
+
return { signature, blockhash, lastValidBlockHeight };
|
|
21433
21431
|
};
|
|
21434
21432
|
|
|
21435
21433
|
var StellarHorizonAssetType;
|
|
@@ -23314,7 +23312,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23314
23312
|
};
|
|
23315
23313
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23316
23314
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23317
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23315
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-DN6Mr9e8.js'); });
|
|
23318
23316
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23319
23317
|
};
|
|
23320
23318
|
function getTokenAssetsKey(token) {
|
|
@@ -26712,7 +26710,7 @@ function useStellarWallets() {
|
|
|
26712
26710
|
try {
|
|
26713
26711
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26714
26712
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26715
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26713
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-CybwDtEp.js'); });
|
|
26716
26714
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26717
26715
|
const promises = modules.map(async (module) => {
|
|
26718
26716
|
const isAvailable = await module.isAvailable();
|
|
@@ -29355,7 +29353,6 @@ function timeout(ms, promise) {
|
|
|
29355
29353
|
|
|
29356
29354
|
const DEFAULT_REFRESH_INTERVAL_MS$1 = 15000;
|
|
29357
29355
|
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29358
|
-
const { isChainTypeConnected } = useWallet();
|
|
29359
29356
|
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
29360
29357
|
const userAddressParsed = userAddress;
|
|
29361
29358
|
// Only fetch using useBalance if it's a native token
|
|
@@ -29368,7 +29365,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29368
29365
|
isNativeToken &&
|
|
29369
29366
|
!!chain &&
|
|
29370
29367
|
chain.chainType === squidTypes.ChainType.EVM &&
|
|
29371
|
-
|
|
29368
|
+
isWalletAddressValid(chain, userAddress),
|
|
29372
29369
|
refetchInterval: refreshIntervalMs,
|
|
29373
29370
|
retry: 2,
|
|
29374
29371
|
},
|
|
@@ -29382,10 +29379,10 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29382
29379
|
args: [userAddressParsed],
|
|
29383
29380
|
chainId: Number(chain?.chainId),
|
|
29384
29381
|
query: {
|
|
29385
|
-
enabled:
|
|
29386
|
-
enabled &&
|
|
29382
|
+
enabled: enabled &&
|
|
29387
29383
|
!!userAddress &&
|
|
29388
|
-
!isNativeToken
|
|
29384
|
+
!isNativeToken &&
|
|
29385
|
+
isWalletAddressValid(chain, userAddress),
|
|
29389
29386
|
refetchInterval: refreshIntervalMs,
|
|
29390
29387
|
retry: 2,
|
|
29391
29388
|
},
|
|
@@ -29555,12 +29552,12 @@ function useNativeTokenForChain(chain) {
|
|
|
29555
29552
|
}
|
|
29556
29553
|
|
|
29557
29554
|
const useEvmNativeBalance = ({ address, chain, }) => {
|
|
29558
|
-
const { isChainTypeConnected } = useWallet();
|
|
29559
29555
|
const { data: nativeEvmBalance, isLoading } = wagmi.useBalance({
|
|
29560
29556
|
address: address,
|
|
29561
29557
|
chainId: Number(chain?.chainId),
|
|
29562
29558
|
query: {
|
|
29563
|
-
enabled:
|
|
29559
|
+
enabled: chain?.chainType === squidTypes.ChainType.EVM &&
|
|
29560
|
+
isWalletAddressValid(chain, address),
|
|
29564
29561
|
refetchInterval: 10000,
|
|
29565
29562
|
staleTime: 5000,
|
|
29566
29563
|
refetchOnWindowFocus: true,
|
|
@@ -29582,13 +29579,13 @@ const useEvmNativeBalance = ({ address, chain, }) => {
|
|
|
29582
29579
|
};
|
|
29583
29580
|
};
|
|
29584
29581
|
const useCosmosNativeBalance = ({ address, chain, }) => {
|
|
29585
|
-
const { isConnected: isCosmosConnected } = useCosmosContext();
|
|
29586
29582
|
const { nativeToken: nativeCosmosToken } = useNativeTokenForChain(chain);
|
|
29587
29583
|
const { balance: rawBalance, isLoading } = useCosmosBalance({
|
|
29588
29584
|
chain,
|
|
29589
29585
|
token: nativeCosmosToken,
|
|
29590
29586
|
userAddress: address,
|
|
29591
|
-
enabled:
|
|
29587
|
+
enabled: chain?.chainType === squidTypes.ChainType.COSMOS &&
|
|
29588
|
+
isWalletAddressValid(chain, address),
|
|
29592
29589
|
refreshIntervalMs: 10000,
|
|
29593
29590
|
});
|
|
29594
29591
|
const balance = React.useMemo(() => {
|
|
@@ -29636,9 +29633,9 @@ const useSolanaNativeBalance = ({ chain, address, }) => {
|
|
|
29636
29633
|
const balance = await getSolanaNativeBalance(address);
|
|
29637
29634
|
return formatBNToReadable(balance, nativeToken.decimals);
|
|
29638
29635
|
}, {
|
|
29639
|
-
enabled:
|
|
29640
|
-
|
|
29641
|
-
chain
|
|
29636
|
+
enabled: nativeToken?.decimals != null &&
|
|
29637
|
+
chain?.chainType === squidTypes.ChainType.SOLANA &&
|
|
29638
|
+
isWalletAddressValid(chain, address),
|
|
29642
29639
|
refetchInterval: 40000,
|
|
29643
29640
|
staleTime: 20000,
|
|
29644
29641
|
refetchOnWindowFocus: true,
|
|
@@ -29663,6 +29660,8 @@ const useSuiNativeBalance = ({ address, chain, }) => {
|
|
|
29663
29660
|
chain,
|
|
29664
29661
|
token: nativeToken,
|
|
29665
29662
|
userAddress: address,
|
|
29663
|
+
enabled: chain?.chainType === squidTypes.ChainType.SUI &&
|
|
29664
|
+
isWalletAddressValid(chain, address),
|
|
29666
29665
|
});
|
|
29667
29666
|
const balance = React.useMemo(() => {
|
|
29668
29667
|
if (nativeToken?.decimals && rawBalance) {
|
|
@@ -29683,7 +29682,8 @@ const useXrplNativeBalance = ({ address, chain, }) => {
|
|
|
29683
29682
|
chain,
|
|
29684
29683
|
token: nativeToken,
|
|
29685
29684
|
userAddress: address,
|
|
29686
|
-
enabled: chain?.chainType === squidTypes.ChainType.XRPL
|
|
29685
|
+
enabled: chain?.chainType === squidTypes.ChainType.XRPL &&
|
|
29686
|
+
isWalletAddressValid(chain, address),
|
|
29687
29687
|
});
|
|
29688
29688
|
const balance = React.useMemo(() => {
|
|
29689
29689
|
if (nativeToken?.decimals && rawBalance) {
|
|
@@ -29704,7 +29704,8 @@ const useStellarNativeBalance = ({ address, chain, }) => {
|
|
|
29704
29704
|
chain,
|
|
29705
29705
|
token: nativeToken,
|
|
29706
29706
|
userAddress: address,
|
|
29707
|
-
enabled: chain?.chainType === squidTypes.ChainType.STELLAR
|
|
29707
|
+
enabled: chain?.chainType === squidTypes.ChainType.STELLAR &&
|
|
29708
|
+
isWalletAddressValid(chain, address),
|
|
29708
29709
|
});
|
|
29709
29710
|
const balance = React.useMemo(() => {
|
|
29710
29711
|
if (nativeToken?.decimals && rawBalance) {
|
|
@@ -30032,7 +30033,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30032
30033
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30033
30034
|
if (!optionalChains.length)
|
|
30034
30035
|
return;
|
|
30035
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30036
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-BOb7ZHW7.js'); });
|
|
30036
30037
|
const rawProvider = await EthereumProvider.init({
|
|
30037
30038
|
...restParameters,
|
|
30038
30039
|
disableProviderPing: true,
|
|
@@ -31844,7 +31845,7 @@ async function sendTransactionCosmos({ amount, rpcUrl, signer, to, token, native
|
|
|
31844
31845
|
}
|
|
31845
31846
|
async function sendTransactionSolana({ signer, amount, to, token, connection, }) {
|
|
31846
31847
|
const amountBn = BigInt(amount);
|
|
31847
|
-
const txHash = await executeSolanaTransfer({
|
|
31848
|
+
const { signature: txHash } = await executeSolanaTransfer({
|
|
31848
31849
|
amount: amountBn,
|
|
31849
31850
|
connection,
|
|
31850
31851
|
signer,
|
|
@@ -36168,7 +36169,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36168
36169
|
});
|
|
36169
36170
|
const swapMutationSolana = reactQuery.useMutation(async ({ id, route }) => {
|
|
36170
36171
|
try {
|
|
36171
|
-
if (!route) {
|
|
36172
|
+
if (!route?.transactionRequest) {
|
|
36172
36173
|
throw new Error("Route is required");
|
|
36173
36174
|
}
|
|
36174
36175
|
if (!solanaSigner) {
|
|
@@ -36177,69 +36178,69 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36177
36178
|
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
36178
36179
|
throw new Error("From or to address is required");
|
|
36179
36180
|
}
|
|
36180
|
-
|
|
36181
|
-
|
|
36182
|
-
|
|
36183
|
-
|
|
36184
|
-
|
|
36185
|
-
|
|
36186
|
-
|
|
36187
|
-
|
|
36188
|
-
|
|
36181
|
+
let txResult;
|
|
36182
|
+
let transactionIdForStatus;
|
|
36183
|
+
switch (route.transactionRequest.type) {
|
|
36184
|
+
case squidTypes.SquidDataType.ChainflipDepositAddress: {
|
|
36185
|
+
// Means it's a transfer to a deposit address
|
|
36186
|
+
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
36187
|
+
const depositData = useDepositAddressStore.getState().deposit;
|
|
36188
|
+
if (!depositData?.depositAddress) {
|
|
36189
|
+
throw new Error("Deposit address is required");
|
|
36190
|
+
}
|
|
36191
|
+
txResult = await executeSolanaTransfer({
|
|
36192
|
+
amount: BigInt(route.params.fromAmount),
|
|
36193
|
+
target: depositData.depositAddress,
|
|
36194
|
+
signer: solanaSigner,
|
|
36195
|
+
connection: solanaConnection,
|
|
36196
|
+
sourceToken: findToken(route.params.fromToken, route.params.fromChain),
|
|
36197
|
+
});
|
|
36198
|
+
transactionIdForStatus = depositData.chainflipStatusTrackingId;
|
|
36199
|
+
break;
|
|
36200
|
+
}
|
|
36201
|
+
case squidTypes.SquidDataType.OnChainExecution: {
|
|
36202
|
+
txResult = await executeSolanaSwap({
|
|
36203
|
+
transactionRequest: route.transactionRequest,
|
|
36204
|
+
signer: solanaSigner,
|
|
36205
|
+
connection: solanaConnection,
|
|
36206
|
+
});
|
|
36207
|
+
break;
|
|
36208
|
+
}
|
|
36209
|
+
case squidTypes.SquidDataType.DepositAddressCalldata: {
|
|
36210
|
+
txResult = await executeSolanaDepositAddressCalldata({
|
|
36211
|
+
transactionRequest: route.transactionRequest,
|
|
36212
|
+
signer: solanaSigner,
|
|
36213
|
+
connection: solanaConnection,
|
|
36214
|
+
});
|
|
36215
|
+
break;
|
|
36216
|
+
}
|
|
36217
|
+
default: {
|
|
36218
|
+
throw new Error(`Unhandled transaction type: ${route.transactionRequest.type}`);
|
|
36189
36219
|
}
|
|
36190
|
-
const signature = await executeSolanaTransfer({
|
|
36191
|
-
amount: BigInt(route.params.fromAmount),
|
|
36192
|
-
target: depositData.depositAddress,
|
|
36193
|
-
signer: solanaSigner,
|
|
36194
|
-
connection: solanaConnection,
|
|
36195
|
-
sourceToken: findToken(route.params.fromToken, route?.params?.fromChain),
|
|
36196
|
-
onSigned: (txHash) => {
|
|
36197
|
-
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
36198
|
-
const txParams = setTransactionState({
|
|
36199
|
-
route,
|
|
36200
|
-
txHash,
|
|
36201
|
-
transactionIdForStatus: depositData.chainflipStatusTrackingId,
|
|
36202
|
-
userAddress: sourceUserAddress,
|
|
36203
|
-
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36204
|
-
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
36205
|
-
id,
|
|
36206
|
-
});
|
|
36207
|
-
if (txParams) {
|
|
36208
|
-
addSwapTransaction({
|
|
36209
|
-
...txParams,
|
|
36210
|
-
params: route.params,
|
|
36211
|
-
estimate: route.estimate,
|
|
36212
|
-
});
|
|
36213
|
-
}
|
|
36214
|
-
},
|
|
36215
|
-
});
|
|
36216
|
-
return signature;
|
|
36217
36220
|
}
|
|
36218
|
-
const signature =
|
|
36221
|
+
const { signature: txHash, blockhash, lastValidBlockHeight } = txResult;
|
|
36222
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
36223
|
+
const txParams = setTransactionState({
|
|
36219
36224
|
route,
|
|
36220
|
-
|
|
36221
|
-
|
|
36222
|
-
|
|
36223
|
-
|
|
36224
|
-
|
|
36225
|
-
|
|
36226
|
-
|
|
36227
|
-
|
|
36228
|
-
|
|
36229
|
-
|
|
36230
|
-
|
|
36231
|
-
|
|
36232
|
-
|
|
36233
|
-
|
|
36234
|
-
|
|
36235
|
-
|
|
36236
|
-
|
|
36237
|
-
|
|
36238
|
-
});
|
|
36239
|
-
}
|
|
36240
|
-
},
|
|
36225
|
+
txHash,
|
|
36226
|
+
userAddress: sourceUserAddress,
|
|
36227
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36228
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
36229
|
+
id,
|
|
36230
|
+
transactionIdForStatus,
|
|
36231
|
+
});
|
|
36232
|
+
if (txParams) {
|
|
36233
|
+
addSwapTransaction({
|
|
36234
|
+
...txParams,
|
|
36235
|
+
params: route.params,
|
|
36236
|
+
estimate: route.estimate,
|
|
36237
|
+
});
|
|
36238
|
+
}
|
|
36239
|
+
await solanaConnection.confirmTransaction({
|
|
36240
|
+
blockhash,
|
|
36241
|
+
lastValidBlockHeight,
|
|
36242
|
+
signature: txHash,
|
|
36241
36243
|
});
|
|
36242
|
-
return signature;
|
|
36243
36244
|
}
|
|
36244
36245
|
catch (error) {
|
|
36245
36246
|
console.error("Solana transaction failed:", error);
|
|
@@ -36286,47 +36287,91 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36286
36287
|
},
|
|
36287
36288
|
});
|
|
36288
36289
|
const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
|
|
36289
|
-
|
|
36290
|
-
|
|
36291
|
-
|
|
36292
|
-
}
|
|
36293
|
-
if (!
|
|
36294
|
-
throw new Error(
|
|
36290
|
+
console.log("Validating route", {
|
|
36291
|
+
bitcoinSigner,
|
|
36292
|
+
route,
|
|
36293
|
+
});
|
|
36294
|
+
if (!bitcoinSigner || !route?.transactionRequest) {
|
|
36295
|
+
throw new Error("Need all parameters");
|
|
36295
36296
|
}
|
|
36296
|
-
|
|
36297
|
-
|
|
36298
|
-
|
|
36299
|
-
|
|
36300
|
-
|
|
36301
|
-
|
|
36302
|
-
|
|
36297
|
+
switch (route.transactionRequest.type) {
|
|
36298
|
+
case squidTypes.SquidDataType.ChainflipDepositAddress: {
|
|
36299
|
+
const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
36300
|
+
const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
|
|
36301
|
+
if (!allParamsValid) {
|
|
36302
|
+
throw new Error("Need all parameters");
|
|
36303
|
+
}
|
|
36304
|
+
await changeNetworkIfNeeded.mutateAsync();
|
|
36305
|
+
dispatchSignatureRequestEvent(route);
|
|
36306
|
+
const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
|
|
36307
|
+
if (txHash) {
|
|
36308
|
+
resetQueriesAfterTxSigned();
|
|
36309
|
+
}
|
|
36310
|
+
// Dispatch event so it can be listened from outside the widget
|
|
36311
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
36312
|
+
if (route.transactionRequest) {
|
|
36313
|
+
const txParams = setTransactionState({
|
|
36314
|
+
route,
|
|
36315
|
+
txHash,
|
|
36316
|
+
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
36317
|
+
// instead of the Bitcoin transaction hash
|
|
36318
|
+
transactionIdForStatus: chainflipStatusTrackingId,
|
|
36319
|
+
userAddress: sourceUserAddress,
|
|
36320
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36321
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
36322
|
+
axelarUrl: undefined,
|
|
36323
|
+
id,
|
|
36324
|
+
});
|
|
36325
|
+
if (txParams) {
|
|
36326
|
+
addSwapTransaction({
|
|
36327
|
+
...txParams,
|
|
36328
|
+
params: route.params,
|
|
36329
|
+
estimate: route.estimate,
|
|
36330
|
+
});
|
|
36331
|
+
}
|
|
36332
|
+
}
|
|
36333
|
+
break;
|
|
36303
36334
|
}
|
|
36304
|
-
|
|
36305
|
-
|
|
36306
|
-
|
|
36307
|
-
|
|
36308
|
-
route
|
|
36309
|
-
|
|
36310
|
-
|
|
36311
|
-
|
|
36312
|
-
|
|
36313
|
-
|
|
36314
|
-
|
|
36315
|
-
|
|
36316
|
-
|
|
36317
|
-
|
|
36318
|
-
}
|
|
36319
|
-
|
|
36320
|
-
|
|
36321
|
-
|
|
36322
|
-
|
|
36323
|
-
|
|
36335
|
+
case squidTypes.SquidDataType.DepositAddressCalldata: {
|
|
36336
|
+
console.log(`Route type: ${route.transactionRequest?.type}`);
|
|
36337
|
+
if (!isOnChainTxData(route.transactionRequest)) {
|
|
36338
|
+
console.log("Invalid route data", route.transactionRequest);
|
|
36339
|
+
throw new Error("Invalid route data");
|
|
36340
|
+
}
|
|
36341
|
+
const { data: transactionHex } = route.transactionRequest;
|
|
36342
|
+
await changeNetworkIfNeeded.mutateAsync();
|
|
36343
|
+
dispatchSignatureRequestEvent(route);
|
|
36344
|
+
console.log("Signing psbt", { transactionHex });
|
|
36345
|
+
const { txHash } = await bitcoinSigner.signPsbt(transactionHex);
|
|
36346
|
+
console.log("Signed psbt", { txHash });
|
|
36347
|
+
if (txHash) {
|
|
36348
|
+
resetQueriesAfterTxSigned();
|
|
36349
|
+
}
|
|
36350
|
+
// Dispatch event so it can be listened from outside the widget
|
|
36351
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
36352
|
+
if (route.transactionRequest) {
|
|
36353
|
+
const txParams = setTransactionState({
|
|
36354
|
+
route,
|
|
36355
|
+
txHash,
|
|
36356
|
+
userAddress: sourceUserAddress,
|
|
36357
|
+
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36358
|
+
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
36359
|
+
axelarUrl: undefined,
|
|
36360
|
+
id,
|
|
36324
36361
|
});
|
|
36362
|
+
if (txParams) {
|
|
36363
|
+
addSwapTransaction({
|
|
36364
|
+
...txParams,
|
|
36365
|
+
params: route.params,
|
|
36366
|
+
estimate: route.estimate,
|
|
36367
|
+
});
|
|
36368
|
+
}
|
|
36325
36369
|
}
|
|
36370
|
+
break;
|
|
36371
|
+
}
|
|
36372
|
+
default: {
|
|
36373
|
+
throw new Error(`Unhandled route type ${route.transactionRequest.type}`);
|
|
36326
36374
|
}
|
|
36327
|
-
}
|
|
36328
|
-
else {
|
|
36329
|
-
throw new Error("Need all parameters");
|
|
36330
36375
|
}
|
|
36331
36376
|
});
|
|
36332
36377
|
const swapMutationXrpl = reactQuery.useMutation(async ({ id, route }) => {
|
|
@@ -37513,6 +37558,7 @@ exports.createQuoteRequestParamsHash = createQuoteRequestParamsHash;
|
|
|
37513
37558
|
exports.definedInWindow = definedInWindow;
|
|
37514
37559
|
exports.destinationAddressResetValue = destinationAddressResetValue;
|
|
37515
37560
|
exports.er = er;
|
|
37561
|
+
exports.executeSolanaDepositAddressCalldata = executeSolanaDepositAddressCalldata;
|
|
37516
37562
|
exports.executeSolanaSwap = executeSolanaSwap;
|
|
37517
37563
|
exports.executeSolanaTransfer = executeSolanaTransfer;
|
|
37518
37564
|
exports.fallbackAddressResetValue = fallbackAddressResetValue;
|
|
@@ -37590,7 +37636,6 @@ exports.is404Error = is404Error;
|
|
|
37590
37636
|
exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
|
|
37591
37637
|
exports.isCoralBridgeAction = isCoralBridgeAction;
|
|
37592
37638
|
exports.isCosmosAddressValid = isCosmosAddressValid;
|
|
37593
|
-
exports.isDepositRoute = isDepositRoute;
|
|
37594
37639
|
exports.isEmptyObject = isEmptyObject;
|
|
37595
37640
|
exports.isEvmChainNotSupportedError = isEvmChainNotSupportedError;
|
|
37596
37641
|
exports.isEvmosChain = isEvmosChain;
|
|
@@ -37736,4 +37781,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37736
37781
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37737
37782
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37738
37783
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37739
|
-
//# sourceMappingURL=index-
|
|
37784
|
+
//# sourceMappingURL=index-CpphPhUS.js.map
|