Skip to content

Commit 53780f7

Browse files
committed
refactor: use cross-chain stream api
; Conflicts: ; apps/kyberswap-interface/src/pages/CrossChainSwap/hooks/useCrossChainSwap.tsx
1 parent f9952c7 commit 53780f7

File tree

9 files changed

+428
-84
lines changed

9 files changed

+428
-84
lines changed

apps/kyberswap-interface/.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ VITE_ZAP_EARN_URL=https://zap-earn-service-v3.kyberengineering.io/api
4646

4747
VITE_AFFILIATE_SERVICE=https://pre-affiliate-service.kyberengineering.io/api
4848
VITE_OAUTH_INTERCEPTOR_API=https://pre-oauth-interceptor-api.kyberengineering.io/api
49+
VITE_SOLANA_RPC=https://solana.kyberengineering.io
50+
51+
VITE_CROSSCHAIN_AGGREGATOR_API=https://pre-crosschain-aggregator.kyberengineering.io

apps/kyberswap-interface/.env.dev

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ VITE_ZAP_EARN_URL=https://zap-earn-service-v3.kyberengineering.io/api
4747

4848
VITE_AFFILIATE_SERVICE=https://pre-affiliate-service.kyberengineering.io/api
4949
VITE_OAUTH_INTERCEPTOR_API=https://pre-oauth-interceptor-api.kyberengineering.io/api
50+
VITE_SOLANA_RPC=https://solana.kyberengineering.io
51+
52+
VITE_CROSSCHAIN_AGGREGATOR_API=https://pre-crosschain-aggregator.kyberengineering.io

apps/kyberswap-interface/.env.production

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ VITE_ZAP_EARN_URL=https://zap-earn-service-v3.kyberengineering.io/api
4646

4747
VITE_AFFILIATE_SERVICE=https://affiliate-service.kyberengineering.io/api
4848
VITE_SOLANA_RPC=https://solana.kyberengineering.io
49+
50+
VITE_CROSSCHAIN_AGGREGATOR_API=https://pre-crosschain-aggregator.kyberengineering.io

apps/kyberswap-interface/.env.stg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ VITE_ZAP_EARN_URL=https://zap-earn-service-v3.kyberengineering.io/api
4545

4646
VITE_AFFILIATE_SERVICE=https://pre-affiliate-service.kyberengineering.io/api
4747
VITE_OAUTH_INTERCEPTOR_API=https://pre-oauth-interceptor-api.kyberengineering.io/api
48+
VITE_SOLANA_RPC=https://solana.kyberengineering.io
49+
50+
VITE_CROSSCHAIN_AGGREGATOR_API=https://pre-crosschain-aggregator.kyberengineering.io

apps/kyberswap-interface/src/constants/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const REFERRAL_URL = required('REFERRAL_URL')
5757
export const TOKEN_API_URL = required('TOKEN_API_URL')
5858
export const AFFILIATE_SERVICE_URL = required('AFFILIATE_SERVICE')
5959
export const SOLANA_RPC = required('SOLANA_RPC')
60+
export const CROSSCHAIN_AGGREGATOR_API = required('CROSSCHAIN_AGGREGATOR_API')
6061

6162
type FirebaseConfig = {
6263
apiKey: string

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export class OptimexAdapter extends BaseSwapAdapter {
4949
constructor() {
5050
super()
5151
this.tokens = []
52+
53+
// Initialize tokens asynchronously when the adapter is created
54+
this.getTokens().catch(error => {
55+
console.error('Failed to initialize Optimex tokens:', error)
56+
})
5257
}
5358

5459
private async getTokens() {
@@ -251,6 +256,10 @@ export class OptimexAdapter extends BaseSwapAdapter {
251256
_nearWallet: any,
252257
sendBtcFn?: (params: { recipient: string; amount: string | number }) => Promise<string>,
253258
): Promise<NormalizedTxResponse> {
259+
if (!this.tokens?.length) {
260+
await this.getTokens()
261+
}
262+
254263
// For EVM -> BTC flow, txData should already exist from getQuote
255264
// For BTC -> EVM flow, we need to initiate the trade here
256265
let txData: { deposit_address: string; payload?: string; trade_id: string }

apps/kyberswap-interface/src/pages/CrossChainSwap/components/SwapAction.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const SwapAction = ({ setShowBtcModal }: { setShowBtcModal: (val: boolean
3131
toChainId,
3232
currencyIn,
3333
currencyOut,
34-
allLoading,
3534
loading,
3635
selectedQuote,
3736
recipient,
@@ -79,7 +78,7 @@ export const SwapAction = ({ setShowBtcModal }: { setShowBtcModal: (val: boolean
7978
onClick: () => {},
8079
}
8180
}
82-
if (allLoading)
81+
if (loading)
8382
return {
8483
label: t`Finding the best route...`,
8584
disabled: true,

0 commit comments

Comments
 (0)