Skip to content

Commit 2c96d96

Browse files
committed
revert and fix types
1 parent 9e9a34b commit 2c96d96

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

common/src/utils/ofac.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,12 @@ const fetchTree = async (url: string): Promise<any> => {
1414
throw new Error(`HTTP error fetching ${url}! status: ${res.status}`);
1515
}
1616
const responseData = await res.json();
17-
// Accept either wrapped { status: 'success', data: ... } or raw payloads
18-
if (responseData && typeof responseData === 'object') {
19-
if ('status' in responseData || 'data' in responseData) {
20-
if (responseData.status !== 'success' || !responseData.data) {
21-
throw new Error(
22-
`Failed to fetch tree from ${url}: ${responseData.message || 'Invalid response format'}`
23-
);
24-
}
25-
return responseData.data;
26-
}
27-
// Raw tree payload (already the tree)
28-
return responseData;
17+
if (responseData.status !== 'success' || !responseData.data) {
18+
throw new Error(
19+
`Failed to fetch tree from ${url}: ${responseData.message || 'Invalid response format'}`
20+
);
2921
}
30-
throw new Error(`Failed to fetch tree from ${url}: Unexpected response type`);
22+
return responseData.data;
3123
};
3224

3325
// Main public helper that retrieves the three OFAC trees depending on the variant (passport vs id_card).

packages/mobile-sdk-alpha/tests/stores/protocolStore.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ describe('protocolStore.fetch_ofac_trees', () => {
3131
'name-yob': { root: ['yob'] },
3232
};
3333

34-
vi.spyOn(global, 'fetch').mockImplementation((url: string) => {
34+
vi.spyOn(global, 'fetch').mockImplementation((input: string | Request | URL, _init?: RequestInit) => {
35+
const url = typeof input === 'string' ? input : input.toString();
3536
const key = url.includes('passport-no-nationality')
3637
? 'passport-no-nationality'
3738
: url.includes('name-dob')
@@ -55,7 +56,8 @@ describe('protocolStore.fetch_ofac_trees', () => {
5556
'name-yob': { status: 'success', data: { root: ['yob'] } },
5657
};
5758

58-
vi.spyOn(global, 'fetch').mockImplementation((url: string) => {
59+
vi.spyOn(global, 'fetch').mockImplementation((input: string | Request | URL, _init?: RequestInit) => {
60+
const url = typeof input === 'string' ? input : input.toString();
5961
const key = url.includes('passport-no-nationality')
6062
? 'passport-no-nationality'
6163
: url.includes('name-dob')

0 commit comments

Comments
 (0)