@@ -11,8 +11,8 @@ import { AssetHubSwapHandler } from '@subwallet/extension-base/services/swap-ser
11
11
import { SwapBaseInterface } from '@subwallet/extension-base/services/swap-service/handler/base-handler' ;
12
12
import { ChainflipSwapHandler } from '@subwallet/extension-base/services/swap-service/handler/chainflip-handler' ;
13
13
import { HydradxHandler } from '@subwallet/extension-base/services/swap-service/handler/hydradx-handler' ;
14
- import { _PROVIDER_TO_SUPPORTED_PAIR_MAP , getSwapAltToken , SWAP_QUOTE_TIMEOUT_MAP } from '@subwallet/extension-base/services/swap-service/utils' ;
15
- import { BasicTxErrorType } from '@subwallet/extension-base/types' ;
14
+ import { _PROVIDER_TO_SUPPORTED_PAIR_MAP , generateSwapPairs , getSwapAltToken , SWAP_QUOTE_TIMEOUT_MAP } from '@subwallet/extension-base/services/swap-service/utils' ;
15
+ import { BasicTxErrorType , SwapRequestV2 } from '@subwallet/extension-base/types' ;
16
16
import { CommonOptimalPath , DEFAULT_FIRST_STEP , MOCK_STEP_FEE } from '@subwallet/extension-base/types/service-base' ;
17
17
import { _SUPPORTED_SWAP_PROVIDERS , OptimalSwapPathParams , QuoteAskResponse , SwapErrorType , SwapPair , SwapProviderId , SwapQuote , SwapQuoteResponse , SwapRequest , SwapRequestResult , SwapStepType , SwapSubmitParams , SwapSubmitStepData , ValidateSwapProcessParams } from '@subwallet/extension-base/types/swap' ;
18
18
import { createPromiseHandler , PromiseHandler } from '@subwallet/extension-base/utils' ;
@@ -125,12 +125,39 @@ export class SwapService implements ServiceWithProcessInterface, StoppableServic
125
125
selectedQuote : swapQuoteResponse . optimalQuote
126
126
} ) ;
127
127
128
+ console . log ( 'optimalProcess' , optimalProcess ) ;
129
+ console . log ( 'swapQuoteResponse' , swapQuoteResponse ) ;
130
+
128
131
return {
129
132
process : optimalProcess ,
130
133
quote : swapQuoteResponse
131
134
} as SwapRequestResult ;
132
135
}
133
136
137
+ public handleSwapRequestV2 ( request : SwapRequestV2 ) {
138
+ const { fromToken, toToken } = request ;
139
+ const fromTokenInfo = this . chainService . getAssetBySlug ( fromToken ) ;
140
+ const toTokenInfo = this . chainService . getAssetBySlug ( toToken ) ;
141
+ const substrateApi = this . chainService . getSubstrateApi ( fromTokenInfo . originChain ) ;
142
+ const steps = [ ] ;
143
+
144
+ const destinations = generateSwapPairs ( substrateApi , this . chainService , fromTokenInfo , 1 ) ;
145
+
146
+ if ( destinations . length > 0 && destinations . includes ( toTokenInfo ) ) {
147
+ steps . push ( {
148
+ action : 'SWAP' , // todo: check XCM / SWAP
149
+ toToken
150
+ } ) ;
151
+ }
152
+
153
+ if ( steps . length ) {
154
+ return steps ;
155
+ }
156
+
157
+ // todo: try find process
158
+ return steps ;
159
+ }
160
+
134
161
public async getLatestQuotes ( request : SwapRequest ) : Promise < SwapQuoteResponse > {
135
162
request . pair . metadata = this . getSwapPairMetadata ( request . pair . slug ) ; // todo: improve this
136
163
const quoteAskResponses = await this . askProvidersForQuote ( request ) ;
0 commit comments