diff --git a/packages/assets-controllers/CHANGELOG.md b/packages/assets-controllers/CHANGELOG.md index 29582c49de..007c7fa56c 100644 --- a/packages/assets-controllers/CHANGELOG.md +++ b/packages/assets-controllers/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Add `offhours` field to `TokenRwaData` and `RwaTokenData` types to support off-hours RWA trading windows ([#9792](https://github.com/MetaMask/core/pull/9792)) + - `offhours.nextOpen`: ISO-8601 datetime when the next off-hours window opens + - `offhours.nextClose`: ISO-8601 datetime when the next off-hours window closes + - Field is only present when the asset's source reports off-hours tradability; absence means off-hours trading is not supported - Add 0G (`16661`/`0x4115`) entries in `multicall.ts` and `codefi-v2.ts` ([#9760](https://github.com/MetaMask/core/pull/9760)) ### Changed diff --git a/packages/assets-controllers/src/token-service.test.ts b/packages/assets-controllers/src/token-service.test.ts index 5fdb91870e..6efdefec43 100644 --- a/packages/assets-controllers/src/token-service.test.ts +++ b/packages/assets-controllers/src/token-service.test.ts @@ -2003,6 +2003,47 @@ describe('Token service', () => { expect(result).toStrictEqual(sampleRwasResponse); }); + it('passes through offhours field when present in the response', async () => { + const responseWithOffhours = { + ...sampleRwasResponse, + data: [ + { + ...sampleRwasResponse.data[0], + rwaData: { + ...sampleRwasResponse.data[0].rwaData, + offhours: { + nextOpen: '2026-08-08T00:05:00Z', + nextClose: '2026-08-09T23:55:00Z', + }, + }, + }, + ], + }; + + nock(TOKEN_END_POINT_API) + .get('/v1/rwas?limit=100') + .reply(200, responseWithOffhours) + .persist(); + + const result = await fetchRwas(); + + expect(result.data[0].rwaData.offhours).toStrictEqual({ + nextOpen: '2026-08-08T00:05:00Z', + nextClose: '2026-08-09T23:55:00Z', + }); + }); + + it('returns rwaData without offhours field when asset does not support off-hours trading', async () => { + nock(TOKEN_END_POINT_API) + .get('/v1/rwas?limit=100') + .reply(200, sampleRwasResponse) + .persist(); + + const result = await fetchRwas(); + + expect(result.data[0].rwaData.offhours).toBeUndefined(); + }); + it('throws if the fetch fails', async () => { nock(TOKEN_END_POINT_API).get('/v1/rwas?limit=100').reply(500); diff --git a/packages/assets-controllers/src/token-service.ts b/packages/assets-controllers/src/token-service.ts index acd9f9a45f..206c33fc7a 100644 --- a/packages/assets-controllers/src/token-service.ts +++ b/packages/assets-controllers/src/token-service.ts @@ -380,6 +380,10 @@ export type TokenRwaData = { start?: string; end?: string; }; + offhours?: { + nextOpen?: string; + nextClose?: string; + }; ticker?: string; instrumentType?: string; }; @@ -401,6 +405,10 @@ export type RwaTokenData = { industry: string[]; market?: RwaMarket; nextPause?: Record; + offhours?: { + nextOpen?: string; + nextClose?: string; + }; sharesOutstanding?: number; restrictedCountries?: string[]; updatedAt?: string;