From 0545e3e2768505e416b0f66a7cdd954a1087ba17 Mon Sep 17 00:00:00 2001 From: Satyajeet Kolhapure Date: Wed, 5 Aug 2026 13:16:56 +0100 Subject: [PATCH 1/3] feat(token-service): added offhours fields to rwa token data types in token service --- packages/assets-controllers/CHANGELOG.md | 6 +++ .../src/token-service.test.ts | 41 +++++++++++++++++++ .../assets-controllers/src/token-service.ts | 22 ++++++++++ 3 files changed, 69 insertions(+) diff --git a/packages/assets-controllers/CHANGELOG.md b/packages/assets-controllers/CHANGELOG.md index ed342db8327..4f4f612837b 100644 --- a/packages/assets-controllers/CHANGELOG.md +++ b/packages/assets-controllers/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `offhours` field to `TokenRwaData` and `RwaTokenData` types to support off-hours RWA trading windows ([#XXXX](https://github.com/MetaMask/core/pull/XXXX)) + - `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 ### Changed - Bump `@metamask/account-tree-controller` from `^7.6.0` to `^7.6.1` ([#9791](https://github.com/MetaMask/core/pull/9791)) diff --git a/packages/assets-controllers/src/token-service.test.ts b/packages/assets-controllers/src/token-service.test.ts index 5fdb91870e7..6efdefec434 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 acd9f9a45fa..df7b1ebf449 100644 --- a/packages/assets-controllers/src/token-service.ts +++ b/packages/assets-controllers/src/token-service.ts @@ -380,6 +380,17 @@ export type TokenRwaData = { start?: string; end?: string; }; + /** + * Off-hours trading window. Present only when the asset's source reports + * off-hours tradability (i.e. tradableSessions contains "offhours"). + * When absent, off-hours trading is not supported for this asset. + * nextOpen: when the off-hours window next opens (ISO-8601) + * nextClose: when the off-hours window next closes (ISO-8601) + */ + offhours?: { + nextOpen?: string; + nextClose?: string; + }; ticker?: string; instrumentType?: string; }; @@ -401,6 +412,17 @@ export type RwaTokenData = { industry: string[]; market?: RwaMarket; nextPause?: Record; + /** + * Off-hours trading window. Present only when the asset's source reports + * off-hours tradability (i.e. tradableSessions contains "offhours"). + * When absent, off-hours trading is not supported for this asset. + * nextOpen: when the off-hours window next opens (ISO-8601) + * nextClose: when the off-hours window next closes (ISO-8601) + */ + offhours?: { + nextOpen?: string; + nextClose?: string; + }; sharesOutstanding?: number; restrictedCountries?: string[]; updatedAt?: string; From 0d2f61fbf596a3cfea179be0c3f560774521c9f1 Mon Sep 17 00:00:00 2001 From: Satyajeet Kolhapure Date: Wed, 5 Aug 2026 13:18:37 +0100 Subject: [PATCH 2/3] feat: removed the comment on offhours field --- packages/assets-controllers/src/token-service.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/packages/assets-controllers/src/token-service.ts b/packages/assets-controllers/src/token-service.ts index df7b1ebf449..206c33fc7a7 100644 --- a/packages/assets-controllers/src/token-service.ts +++ b/packages/assets-controllers/src/token-service.ts @@ -380,13 +380,6 @@ export type TokenRwaData = { start?: string; end?: string; }; - /** - * Off-hours trading window. Present only when the asset's source reports - * off-hours tradability (i.e. tradableSessions contains "offhours"). - * When absent, off-hours trading is not supported for this asset. - * nextOpen: when the off-hours window next opens (ISO-8601) - * nextClose: when the off-hours window next closes (ISO-8601) - */ offhours?: { nextOpen?: string; nextClose?: string; @@ -412,13 +405,6 @@ export type RwaTokenData = { industry: string[]; market?: RwaMarket; nextPause?: Record; - /** - * Off-hours trading window. Present only when the asset's source reports - * off-hours tradability (i.e. tradableSessions contains "offhours"). - * When absent, off-hours trading is not supported for this asset. - * nextOpen: when the off-hours window next opens (ISO-8601) - * nextClose: when the off-hours window next closes (ISO-8601) - */ offhours?: { nextOpen?: string; nextClose?: string; From d37358cffad7175d24d8367888c4bb45227f0909 Mon Sep 17 00:00:00 2001 From: Satyajeet Kolhapure <77279246+satyajeetkolhapure@users.noreply.github.com> Date: Wed, 5 Aug 2026 13:25:49 +0100 Subject: [PATCH 3/3] Apply suggestion from @satyajeetkolhapure --- packages/assets-controllers/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/assets-controllers/CHANGELOG.md b/packages/assets-controllers/CHANGELOG.md index 4f4f612837b..a25ec1c1aba 100644 --- a/packages/assets-controllers/CHANGELOG.md +++ b/packages/assets-controllers/CHANGELOG.md @@ -9,7 +9,7 @@ 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 ([#XXXX](https://github.com/MetaMask/core/pull/XXXX)) +- 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