@@ -118,6 +118,123 @@ describe('src/utils.js', () => {
118118 `${ SENTINEL_API_BASE_URL_MAP [ baseChainIdDec ] } /network` ,
119119 ) ;
120120 } ) ;
121+
122+ // Sentinel routing via useSentinel flag
123+ describe ( 'GET_FEES sentinel routing' , ( ) => {
124+ it ( 'returns a sentinel URL when useSentinel is true and chain is in SENTINEL_API_BASE_URL_MAP' , ( ) => {
125+ expect (
126+ utils . getAPIRequestURL ( APIType . GET_FEES , ChainId . mainnet , true ) ,
127+ ) . toBe (
128+ `${ SENTINEL_API_BASE_URL_MAP [ ethereumChainIdDec ] } /v1/networks/${ ethereumChainIdDec } /getFees` ,
129+ ) ;
130+ } ) ;
131+
132+ it ( 'returns the API_BASE_URL when useSentinel is false' , ( ) => {
133+ expect (
134+ utils . getAPIRequestURL ( APIType . GET_FEES , ChainId . mainnet , false ) ,
135+ ) . toBe ( `${ API_BASE_URL } /networks/${ ethereumChainIdDec } /getFees` ) ;
136+ } ) ;
137+
138+ it ( 'returns the API_BASE_URL when useSentinel is true but chain is not in SENTINEL_API_BASE_URL_MAP' , ( ) => {
139+ const unsupportedChainId = '0x539' ; // 1337 — local dev chain, not in map
140+ const chainIdDec = parseInt ( unsupportedChainId , 16 ) ;
141+ expect (
142+ utils . getAPIRequestURL ( APIType . GET_FEES , unsupportedChainId , true ) ,
143+ ) . toBe ( `${ API_BASE_URL } /networks/${ chainIdDec } /getFees` ) ;
144+ } ) ;
145+ } ) ;
146+
147+ describe ( 'SUBMIT_TRANSACTIONS sentinel routing' , ( ) => {
148+ it ( 'returns a sentinel URL when useSentinel is true and chain is in SENTINEL_API_BASE_URL_MAP' , ( ) => {
149+ expect (
150+ utils . getAPIRequestURL (
151+ APIType . SUBMIT_TRANSACTIONS ,
152+ ChainId . mainnet ,
153+ true ,
154+ ) ,
155+ ) . toBe (
156+ `${ SENTINEL_API_BASE_URL_MAP [ ethereumChainIdDec ] } /v1/networks/${ ethereumChainIdDec } /submitTransactions?stxControllerVersion=${ packageJson . version } ` ,
157+ ) ;
158+ } ) ;
159+
160+ it ( 'returns the API_BASE_URL when useSentinel is false' , ( ) => {
161+ expect (
162+ utils . getAPIRequestURL (
163+ APIType . SUBMIT_TRANSACTIONS ,
164+ ChainId . mainnet ,
165+ false ,
166+ ) ,
167+ ) . toBe (
168+ `${ API_BASE_URL } /networks/${ ethereumChainIdDec } /submitTransactions?stxControllerVersion=${ packageJson . version } ` ,
169+ ) ;
170+ } ) ;
171+
172+ it ( 'returns the API_BASE_URL when useSentinel is true but chain is not in SENTINEL_API_BASE_URL_MAP' , ( ) => {
173+ const unsupportedChainId = '0x539' ;
174+ const chainIdDec = parseInt ( unsupportedChainId , 16 ) ;
175+ expect (
176+ utils . getAPIRequestURL (
177+ APIType . SUBMIT_TRANSACTIONS ,
178+ unsupportedChainId ,
179+ true ,
180+ ) ,
181+ ) . toBe (
182+ `${ API_BASE_URL } /networks/${ chainIdDec } /submitTransactions?stxControllerVersion=${ packageJson . version } ` ,
183+ ) ;
184+ } ) ;
185+ } ) ;
186+
187+ describe ( 'CANCEL sentinel routing' , ( ) => {
188+ it ( 'returns a sentinel URL when useSentinel is true and chain is in SENTINEL_API_BASE_URL_MAP' , ( ) => {
189+ expect (
190+ utils . getAPIRequestURL ( APIType . CANCEL , ChainId . mainnet , true ) ,
191+ ) . toBe (
192+ `${ SENTINEL_API_BASE_URL_MAP [ ethereumChainIdDec ] } /v1/networks/${ ethereumChainIdDec } /cancel` ,
193+ ) ;
194+ } ) ;
195+
196+ it ( 'returns the API_BASE_URL when useSentinel is false' , ( ) => {
197+ expect (
198+ utils . getAPIRequestURL ( APIType . CANCEL , ChainId . mainnet , false ) ,
199+ ) . toBe ( `${ API_BASE_URL } /networks/${ ethereumChainIdDec } /cancel` ) ;
200+ } ) ;
201+
202+ it ( 'returns the API_BASE_URL when useSentinel is true but chain is not in SENTINEL_API_BASE_URL_MAP' , ( ) => {
203+ const unsupportedChainId = '0x539' ;
204+ const chainIdDec = parseInt ( unsupportedChainId , 16 ) ;
205+ expect (
206+ utils . getAPIRequestURL ( APIType . CANCEL , unsupportedChainId , true ) ,
207+ ) . toBe ( `${ API_BASE_URL } /networks/${ chainIdDec } /cancel` ) ;
208+ } ) ;
209+ } ) ;
210+
211+ describe ( 'BATCH_STATUS sentinel routing' , ( ) => {
212+ it ( 'returns a sentinel URL when useSentinel is true and chain is in SENTINEL_API_BASE_URL_MAP' , ( ) => {
213+ expect (
214+ utils . getAPIRequestURL ( APIType . BATCH_STATUS , ChainId . mainnet , true ) ,
215+ ) . toBe (
216+ `${ SENTINEL_API_BASE_URL_MAP [ ethereumChainIdDec ] } /v1/networks/${ ethereumChainIdDec } /batchStatus` ,
217+ ) ;
218+ } ) ;
219+
220+ it ( 'returns the API_BASE_URL when useSentinel is false' , ( ) => {
221+ expect (
222+ utils . getAPIRequestURL ( APIType . BATCH_STATUS , ChainId . mainnet , false ) ,
223+ ) . toBe ( `${ API_BASE_URL } /networks/${ ethereumChainIdDec } /batchStatus` ) ;
224+ } ) ;
225+
226+ it ( 'returns the API_BASE_URL when useSentinel is true but chain is not in SENTINEL_API_BASE_URL_MAP' , ( ) => {
227+ const unsupportedChainId = '0x539' ;
228+ const chainIdDec = parseInt ( unsupportedChainId , 16 ) ;
229+ expect (
230+ utils . getAPIRequestURL (
231+ APIType . BATCH_STATUS ,
232+ unsupportedChainId ,
233+ true ,
234+ ) ,
235+ ) . toBe ( `${ API_BASE_URL } /networks/${ chainIdDec } /batchStatus` ) ;
236+ } ) ;
237+ } ) ;
121238 } ) ;
122239
123240 describe ( 'isSmartTransactionStatusResolved' , ( ) => {
0 commit comments