File tree Expand file tree Collapse file tree 14 files changed +228
-91
lines changed Expand file tree Collapse file tree 14 files changed +228
-91
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,16 @@ export abstract class RouteAbstract {
20
20
// protected abstract sendGasFallback: { [key: ChainName]: TokenConfig };
21
21
// protected abstract claimGasFallback: { [key: ChainName]: TokenConfig };
22
22
23
- // Is this route available for the given chain, token and amount specifications?
23
+ // Is this route supported for the given chain, token and amount specifications?
24
+ public abstract isRouteSupported (
25
+ sourceToken : string ,
26
+ destToken : string ,
27
+ amount : string ,
28
+ sourceChain : ChainName | ChainId ,
29
+ destChain : ChainName | ChainId ,
30
+ ) : Promise < boolean > ;
31
+
32
+ // Is this route available for the given chain, fee and amount specifications?
24
33
public abstract isRouteAvailable (
25
34
sourceToken : string ,
26
35
destToken : string ,
Original file line number Diff line number Diff line change @@ -86,6 +86,16 @@ export abstract class BaseRoute extends RouteAbstract {
86
86
} ) ;
87
87
}
88
88
89
+ async isRouteAvailable (
90
+ sourceToken : string ,
91
+ destToken : string ,
92
+ amount : string ,
93
+ sourceChain : ChainName | ChainId ,
94
+ destChain : ChainName | ChainId ,
95
+ ) : Promise < boolean > {
96
+ return true ;
97
+ }
98
+
89
99
async getPreview (
90
100
token : TokenConfig ,
91
101
destToken : TokenConfig ,
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export class BridgeRoute extends BaseRoute {
28
28
readonly NATIVE_GAS_DROPOFF_SUPPORTED : boolean = false ;
29
29
readonly AUTOMATIC_DEPOSIT : boolean = false ;
30
30
31
- async isRouteAvailable (
31
+ async isRouteSupported (
32
32
sourceToken : string ,
33
33
destToken : string ,
34
34
amount : string ,
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ export class CCTPManualRoute extends BaseRoute {
143
143
} ) ;
144
144
}
145
145
146
- async isRouteAvailable (
146
+ async isRouteSupported (
147
147
sourceToken : string ,
148
148
destToken : string ,
149
149
amount : string ,
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ export class CCTPRelayRoute extends CCTPManualRoute implements RelayAbstract {
150
150
} ) ;
151
151
}
152
152
153
- async isRouteAvailable (
153
+ async isRouteSupported (
154
154
sourceToken : string ,
155
155
destToken : string ,
156
156
amount : string ,
@@ -186,8 +186,17 @@ export class CCTPRelayRoute extends CCTPManualRoute implements RelayAbstract {
186
186
const bothHaveRelayer =
187
187
CHAINS [ sourceChainName ] ?. contracts . cctpContracts ?. wormholeCircleRelayer &&
188
188
CHAINS [ destChainName ] ?. contracts . cctpContracts ?. wormholeCircleRelayer ;
189
- if ( ! bothHaveRelayer ) return false ;
190
189
190
+ return ! ! bothHaveRelayer ;
191
+ }
192
+
193
+ async isRouteAvailable (
194
+ sourceToken : string ,
195
+ destToken : string ,
196
+ amount : string ,
197
+ sourceChain : ChainName | ChainId ,
198
+ destChain : ChainName | ChainId ,
199
+ ) : Promise < boolean > {
191
200
let relayerFee ;
192
201
try {
193
202
relayerFee = await this . getRelayerFee (
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export class CosmosGatewayRoute extends BaseRoute {
57
57
return isGatewayChain ( chain ) ;
58
58
}
59
59
60
- async isRouteAvailable (
60
+ async isRouteSupported (
61
61
sourceToken : string ,
62
62
destToken : string ,
63
63
amount : string ,
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export class HashflowRoute extends RouteAbstract {
22
22
return false ;
23
23
}
24
24
25
- async isRouteAvailable (
25
+ async isRouteSupported (
26
26
sourceToken : string ,
27
27
destToken : string ,
28
28
amount : string ,
@@ -35,6 +35,16 @@ export class HashflowRoute extends RouteAbstract {
35
35
36
36
throw new Error ( 'Method not implemented.' ) ;
37
37
}
38
+
39
+ public isRouteAvailable (
40
+ sourceToken : string ,
41
+ destToken : string ,
42
+ amount : string ,
43
+ sourceChain : ChainName | ChainId ,
44
+ destChain : ChainName | ChainId ,
45
+ ) : Promise < boolean > {
46
+ throw new Error ( 'Method not implemented.' ) ;
47
+ }
38
48
isSupportedSourceToken (
39
49
token : TokenConfig | undefined ,
40
50
destToken : TokenConfig | undefined ,
Original file line number Diff line number Diff line change @@ -113,6 +113,27 @@ export class Operator {
113
113
: Route . Bridge ;
114
114
}
115
115
116
+ async isRouteSupported (
117
+ route : Route ,
118
+ sourceToken : string ,
119
+ destToken : string ,
120
+ amount : string ,
121
+ sourceChain : ChainName | ChainId ,
122
+ destChain : ChainName | ChainId ,
123
+ ) : Promise < boolean > {
124
+ if ( ! ROUTES . includes ( route ) ) {
125
+ return false ;
126
+ }
127
+
128
+ const r = this . getRoute ( route ) ;
129
+ return await r . isRouteSupported (
130
+ sourceToken ,
131
+ destToken ,
132
+ amount ,
133
+ sourceChain ,
134
+ destChain ,
135
+ ) ;
136
+ }
116
137
async isRouteAvailable (
117
138
route : Route ,
118
139
sourceToken : string ,
@@ -134,7 +155,6 @@ export class Operator {
134
155
destChain ,
135
156
) ;
136
157
}
137
-
138
158
allSupportedChains ( ) : ChainName [ ] {
139
159
const supported = new Set < ChainName > ( ) ;
140
160
for ( const key in CHAINS ) {
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ export class RelayRoute extends BridgeRoute implements RelayAbstract {
59
59
return ! ! sdkConfig . chains [ chain ] ?. contracts . relayer ;
60
60
}
61
61
62
- async isRouteAvailable (
62
+ async isRouteSupported (
63
63
sourceToken : string ,
64
64
destToken : string ,
65
65
amount : string ,
@@ -70,7 +70,7 @@ export class RelayRoute extends BridgeRoute implements RelayAbstract {
70
70
return false ;
71
71
}
72
72
73
- const isBridgeRouteAvailable = await super . isRouteAvailable (
73
+ const isBridgeRouteAvailable = await super . isRouteSupported (
74
74
sourceToken ,
75
75
destToken ,
76
76
amount ,
@@ -85,10 +85,18 @@ export class RelayRoute extends BridgeRoute implements RelayAbstract {
85
85
}
86
86
const tokenConfig = TOKENS [ sourceToken ] ! ;
87
87
const tokenId = getWrappedTokenId ( tokenConfig ) ;
88
- const accepted = await isAcceptedToken ( tokenId ) ;
89
-
90
- if ( ! accepted ) return false ;
88
+ return isAcceptedToken ( tokenId ) ;
89
+ }
91
90
91
+ async isRouteAvailable (
92
+ sourceToken : string ,
93
+ destToken : string ,
94
+ amount : string ,
95
+ sourceChain : ChainName | ChainId ,
96
+ destChain : ChainName | ChainId ,
97
+ ) : Promise < boolean > {
98
+ const tokenConfig = TOKENS [ sourceToken ] ! ;
99
+ const tokenId = getWrappedTokenId ( tokenConfig ) ;
92
100
let relayerFee ;
93
101
try {
94
102
relayerFee = await this . getRelayerFee (
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export class TBTCRoute extends BaseRoute {
85
85
return wh . toChainId ( token . nativeChain ) === CHAIN_ID_ETH ;
86
86
}
87
87
88
- async isRouteAvailable (
88
+ async isRouteSupported (
89
89
sourceToken : string ,
90
90
destToken : string ,
91
91
amount : string ,
You can’t perform that action at this time.
0 commit comments