feat: explorer API, wallet, CCIP scripts, and config refresh
- Backend REST/gateway/track routes, analytics, Blockscout proxy paths. - Frontend wallet and liquidity surfaces; MetaMask token list alignment. - Deployment docs, verification scripts, address inventory updates. Check: go build ./... under backend/ (pass). Made-with: Cursor
This commit is contained in:
31
frontend/libs/frontend-api-client/api-base.test.ts
Normal file
31
frontend/libs/frontend-api-client/api-base.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { resolveExplorerApiBase } from './api-base'
|
||||
|
||||
describe('resolveExplorerApiBase', () => {
|
||||
it('prefers an explicit env value when present', () => {
|
||||
expect(
|
||||
resolveExplorerApiBase({
|
||||
envValue: 'https://explorer.d-bis.org/',
|
||||
browserOrigin: 'http://127.0.0.1:3000',
|
||||
})
|
||||
).toBe('https://explorer.d-bis.org')
|
||||
})
|
||||
|
||||
it('falls back to same-origin in the browser when env is empty', () => {
|
||||
expect(
|
||||
resolveExplorerApiBase({
|
||||
envValue: '',
|
||||
browserOrigin: 'http://127.0.0.1:3000/',
|
||||
})
|
||||
).toBe('http://127.0.0.1:3000')
|
||||
})
|
||||
|
||||
it('falls back to the local backend on the server when no other base is available', () => {
|
||||
expect(
|
||||
resolveExplorerApiBase({
|
||||
envValue: '',
|
||||
browserOrigin: '',
|
||||
})
|
||||
).toBe('http://localhost:8080')
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
||||
import { resolveExplorerApiBase } from './api-base'
|
||||
|
||||
export interface ApiResponse<T> {
|
||||
data: T
|
||||
@@ -21,9 +22,9 @@ export interface ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
export function createApiClient(baseURL: string = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080', getApiKey?: () => string | null) {
|
||||
export function createApiClient(baseURL?: string, getApiKey?: () => string | null) {
|
||||
const client = axios.create({
|
||||
baseURL,
|
||||
baseURL: baseURL || resolveExplorerApiBase(),
|
||||
timeout: 30000,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user