Skip to content

Commit 2e2b874

Browse files
committed
refactor: use cross-chain stream api
1 parent aa152bb commit 2e2b874

File tree

5 files changed

+345
-69
lines changed

5 files changed

+345
-69
lines changed

apps/kyberswap-interface/src/pages/CrossChainSwap/adapters/BaseSwapAdapter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export interface SwapProvider {
142142
connection?: Connection,
143143
): Promise<NormalizedTxResponse>
144144
getTransactionStatus(p: NormalizedTxResponse): Promise<SwapStatus>
145+
canSupport(category: string): boolean
145146
}
146147
export abstract class BaseSwapAdapter implements SwapProvider {
147148
abstract getName(): string
@@ -156,6 +157,11 @@ export abstract class BaseSwapAdapter implements SwapProvider {
156157
): Promise<NormalizedTxResponse>
157158
abstract getTransactionStatus(p: NormalizedTxResponse): Promise<SwapStatus>
158159

160+
canSupport(_category: string): boolean {
161+
// Default implementation - support all categories
162+
return true
163+
}
164+
159165
protected handleError(error: any): never {
160166
console.error(`[${this.getName()}] Error:`, error)
161167
throw new Error(`${this.getName()} provider error: ${error.message || 'Unknown error'}`)

apps/kyberswap-interface/src/pages/CrossChainSwap/adapters/SymbiosisAdapter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ export class SymbiosisAdapter extends BaseSwapAdapter {
2626
getIcon(): string {
2727
return 'https://app.symbiosis.finance/images/favicon-32x32.png'
2828
}
29+
30+
canSupport(category: string): boolean {
31+
// Symbiosis should only be used for stablePair category
32+
return category === 'stablePair'
33+
}
34+
2935
getSupportedChains(): Chain[] {
3036
return [
3137
ChainId.MAINNET,

apps/kyberswap-interface/src/pages/CrossChainSwap/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class CrossChainSwapFactory {
124124
// CrossChainSwapFactory.getXyFinanceAdapter(),
125125
CrossChainSwapFactory.getNearIntentsAdapter(),
126126
CrossChainSwapFactory.getMayanAdapter(),
127-
// CrossChainSwapFactory.getSymbiosisAdapter(),
127+
CrossChainSwapFactory.getSymbiosisAdapter(),
128128
CrossChainSwapFactory.getDebridgeInstance(),
129129
CrossChainSwapFactory.getLifiInstance(),
130130
CrossChainSwapFactory.getOptimexAdapter(),

0 commit comments

Comments
 (0)