@silentswap/sdk 0.0.91 → 0.0.92

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/bridge.d.ts CHANGED
@@ -291,4 +291,5 @@ export interface SolveUsdcResult {
291
291
  * @param maxImpactPercent - Maximum price impact percentage allowed (default from constants)
292
292
  * @returns Promise resolving to solve result with optimal amounts
293
293
  */
294
- export declare function solveOptimalUsdcAmount(srcChainId: number, srcToken: string, srcAmount: string, userAddress: string, depositCalldata: string | undefined, maxImpactPercent: number, depositorAddress: Hex, evmSignerAddress?: `0x${string}`): Promise<SolveUsdcResult>;
294
+ export declare function solveOptimalUsdcAmount(srcChainId: number, srcToken: string, srcAmount: string, userAddress: string, depositCalldata: string | undefined, maxImpactPercent: number, depositorAddress: Hex, evmSignerAddress?: `0x${string}`, // Optional EVM address for deposit calldata (required for non-EVM swaps: Solana, Bitcoin)
295
+ forceProvider?: 'relay' | 'debridge'): Promise<SolveUsdcResult>;
package/dist/bridge.js CHANGED
@@ -138,8 +138,14 @@ export async function executeDebridgeBridge(quote, executeTransaction, switchCha
138
138
  throw new Error('No transactions in debridge quote');
139
139
  }
140
140
  const tx = quote.txs[0];
141
- // Solana transactions don't need chain switching (handled by connector)
142
- if (!tx.instructions) {
141
+ // Non-EVM transactions don't need EVM chain switching.
142
+ const isNonEvmTx = !!tx.instructions ||
143
+ tx.chainId === N_DEBRIDGE_CHAIN_ID_SOLANA ||
144
+ tx.chainId === N_RELAY_CHAIN_ID_SOLANA ||
145
+ tx.chainId === N_RELAY_CHAIN_ID_BITCOIN ||
146
+ tx.chainId === N_RELAY_CHAIN_ID_TRON ||
147
+ !!tx.psbt;
148
+ if (!isNonEvmTx) {
143
149
  setStep(`Switching to chain ${tx.chainId}`);
144
150
  // Switch to the correct chain for EVM transactions
145
151
  await switchChain(tx.chainId);
@@ -716,8 +722,8 @@ async function solveDebridgeSingleChainUsdcAmount(chainId, srcToken, srcAmount,
716
722
  * @param maxImpactPercent - Maximum price impact percentage allowed (default from constants)
717
723
  * @returns Promise resolving to solve result with optimal amounts
718
724
  */
719
- export async function solveOptimalUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, depositCalldata, maxImpactPercent, depositorAddress, evmSignerAddress // Optional EVM address for deposit calldata (required for non-EVM swaps: Solana, Bitcoin)
720
- ) {
725
+ export async function solveOptimalUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, depositCalldata, maxImpactPercent, depositorAddress, evmSignerAddress, // Optional EVM address for deposit calldata (required for non-EVM swaps: Solana, Bitcoin)
726
+ forceProvider) {
721
727
  // Check if this is a non-EVM chain (Solana, Bitcoin, etc.)
722
728
  const isNonEvmChain = isNonEvmRelayChainId(srcChainId);
723
729
  // For non-EVM chains (Solana, Bitcoin), we need an EVM address for deposit calldata
@@ -733,10 +739,16 @@ export async function solveOptimalUsdcAmount(srcChainId, srcToken, srcAmount, us
733
739
  // userAddress is the source chain address (for user parameter)
734
740
  // evmSignerAddress is the EVM address (for recipient parameter on the destination EVM chain)
735
741
  const recipientAddress = isNonEvmChain && evmSignerAddress ? evmSignerAddress : userAddress;
736
- // Try both providers in parallel
742
+ const useRelay = forceProvider !== 'debridge';
743
+ const useDebridge = forceProvider !== 'relay';
744
+ // Try enabled providers in parallel
737
745
  const [relayResult, debridgeResult] = await Promise.allSettled([
738
- solveRelayUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, calldata, maxImpactPercent, depositorAddress, recipientAddress),
739
- solveDebridgeUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, calldata, maxImpactPercent, depositorAddress),
746
+ useRelay
747
+ ? solveRelayUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, calldata, maxImpactPercent, depositorAddress, recipientAddress)
748
+ : Promise.resolve(null),
749
+ useDebridge
750
+ ? solveDebridgeUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, calldata, maxImpactPercent, depositorAddress)
751
+ : Promise.resolve(null),
740
752
  ]);
741
753
  // Extract results
742
754
  const relayData = relayResult.status === 'fulfilled' ? relayResult.value : null;
@@ -1,5 +1,5 @@
1
1
  import { executeRelayBridge, executeDebridgeBridge, getRelayStatus, getDebridgeStatus, } from './bridge.js';
2
- import { N_RELAY_CHAIN_ID_BITCOIN } from './constants.js';
2
+ import { N_DEBRIDGE_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_BITCOIN, N_RELAY_CHAIN_ID_SOLANA } from './constants.js';
3
3
  /**
4
4
  * Create transaction execution wrapper for framework-agnostic bridge execution
5
5
  * Supports EVM, Solana, and Bitcoin transactions
@@ -14,8 +14,11 @@ export function createTransactionExecutor(walletClient, connector, solanaExecuto
14
14
  }
15
15
  return await bitcoinExecutor(tx);
16
16
  }
17
- // Solana transaction - check for instructions
18
- if (tx.instructions) {
17
+ // Solana transaction - relay instructions or deBridge serialized Solana tx
18
+ const isSolanaTx = !!tx.instructions ||
19
+ tx.chainId === N_RELAY_CHAIN_ID_SOLANA ||
20
+ tx.chainId === N_DEBRIDGE_CHAIN_ID_SOLANA;
21
+ if (isSolanaTx) {
19
22
  if (!solanaExecutor) {
20
23
  throw new Error('Solana transaction detected but Solana executor not provided. ' +
21
24
  'Please provide solanaExecutor when creating the transaction executor.');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silentswap/sdk",
3
3
  "type": "module",
4
- "version": "0.0.91",
4
+ "version": "0.0.92",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "files": [