Skip to content

Commit 7e9d704

Browse files
committed
Add some type definition to fix home asset rwaData lost.
1 parent 967a5b6 commit 7e9d704

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

packages/assets-controllers/src/TokenListController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ export type TokenListToken = {
3434
occurrences: number;
3535
aggregators: string[];
3636
iconUrl: string;
37+
rwaData: {
38+
instrumentType: string;
39+
ticker: string;
40+
market: {
41+
nextOpen: string;
42+
nextClose: string;
43+
};
44+
nextPause: {
45+
start: string;
46+
end: string;
47+
};
48+
};
3749
};
3850

3951
export type TokenListMap = Record<string, TokenListToken>;

packages/assets-controllers/src/token-service.ts

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ export async function fetchTokenListByChainId(
157157
ticker: elm.name?.split(' ')[0] ?? '',
158158
market: {
159159
nextOpen: new Date(new Date().setHours(9, 0, 0, 0)).toISOString(),
160-
nextClose: new Date(new Date().setHours(16, 0, 0, 0)).toISOString(),
160+
nextClose: new Date(
161+
new Date().setHours(16, 0, 0, 0),
162+
).toISOString(),
161163
},
162164
nextPause: {
163165
start: new Date(new Date().setHours(16, 0, 0, 0)).toISOString(),
@@ -174,6 +176,36 @@ export async function fetchTokenListByChainId(
174176
console.log('filteredResult', filteredResult);
175177
return filteredResultWithRwaData;
176178
}
179+
180+
if (Array.isArray(result)) {
181+
// TODO: remove this after development is done
182+
// if the filteredResult has an aggregator that includes 'Ondo' then append rwaData as metadata.
183+
const filteredResultWithRwaData = result.map((elm) => {
184+
const metadata = {
185+
rwaData: {
186+
instrumentType: 'stock',
187+
ticker: elm.name?.split(' ')[0] ?? '',
188+
market: {
189+
nextOpen: new Date(new Date().setHours(9, 0, 0, 0)).toISOString(),
190+
nextClose: new Date(
191+
new Date().setHours(16, 0, 0, 0),
192+
).toISOString(),
193+
},
194+
nextPause: {
195+
start: new Date(new Date().setHours(16, 0, 0, 0)).toISOString(),
196+
end: new Date(new Date().setHours(17, 0, 0, 0)).toISOString(),
197+
},
198+
},
199+
};
200+
if (elm.aggregators.includes('Ondo')) {
201+
return { ...elm, ...metadata };
202+
}
203+
return elm;
204+
});
205+
206+
console.log('filteredResultWithRwaData', filteredResultWithRwaData);
207+
return filteredResultWithRwaData;
208+
}
177209
return result;
178210
}
179211
return undefined;
@@ -242,6 +274,18 @@ export type TrendingAsset = {
242274
h24?: string;
243275
};
244276
labels?: string[];
277+
rwaData?: {
278+
instrumentType: string;
279+
ticker: string;
280+
market: {
281+
nextOpen: string;
282+
nextClose: string;
283+
};
284+
nextPause: {
285+
start: string;
286+
end: string;
287+
};
288+
};
245289
};
246290

247291
/**
@@ -307,7 +351,13 @@ export async function getTrendingTokens({
307351
ticker: elm.name?.split(' ')[0] ?? '',
308352
market: {
309353
nextOpen: new Date(new Date().setHours(9, 0, 0, 0)).toISOString(),
310-
nextClose: new Date(new Date().setHours(16, 0, 0, 0)).toISOString(),
354+
nextClose: new Date(
355+
new Date().setHours(16, 0, 0, 0),
356+
).toISOString(),
357+
},
358+
nextPause: {
359+
start: new Date(new Date().setHours(16, 0, 0, 0)).toISOString(),
360+
end: new Date(new Date().setHours(17, 0, 0, 0)).toISOString(),
311361
},
312362
},
313363
};
@@ -357,7 +407,9 @@ export async function fetchTokenMetadata<T>(
357407
ticker: elm.name?.split(' ')[0] ?? '',
358408
market: {
359409
nextOpen: new Date(new Date().setHours(9, 0, 0, 0)).toISOString(),
360-
nextClose: new Date(new Date().setHours(16, 0, 0, 0)).toISOString(),
410+
nextClose: new Date(
411+
new Date().setHours(16, 0, 0, 0),
412+
).toISOString(),
361413
},
362414
nextPause: {
363415
start: new Date(new Date().setHours(16, 0, 0, 0)).toISOString(),

0 commit comments

Comments
 (0)