Skip to content

Commit b0f194e

Browse files
committed
feat: add rwa data to tokens in tokens controller
1 parent a0ad33a commit b0f194e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/assets-controllers/jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ module.exports = merge(baseConfig, {
3232

3333
// We rely on `window` to make requests
3434
testEnvironment: '<rootDir>/jest.environment.js',
35+
36+
// Watchman isn't available in some environments (e.g. sandboxed CI/containers)
37+
watchman: false,
3538
});

packages/assets-controllers/src/TokensController.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { ERC1155Standard } from './Standards/NftStandards/ERC1155/ERC1155Standar
5151
import {
5252
fetchTokenMetadata,
5353
TOKEN_METADATA_NO_SUPPORT_ERROR,
54+
TokenRwaData,
5455
} from './token-service';
5556
import type {
5657
TokenListStateChange,
@@ -288,6 +289,9 @@ export class TokensController extends BaseController<
288289
if (cachedToken && cachedToken.name && !token.name) {
289290
token.name = cachedToken.name; // Update the token name
290291
}
292+
if (cachedToken?.rwaData) {
293+
token.rwaData = cachedToken.rwaData; // Update the token RWA data
294+
}
291295
}
292296
}
293297
}
@@ -426,6 +430,7 @@ export class TokensController extends BaseController<
426430
image,
427431
interactingAddress,
428432
networkClientId,
433+
rwaData,
429434
}: {
430435
address: string;
431436
symbol: string;
@@ -434,6 +439,7 @@ export class TokensController extends BaseController<
434439
image?: string;
435440
interactingAddress?: string;
436441
networkClientId: NetworkClientId;
442+
rwaData?: TokenRwaData;
437443
}): Promise<Token[]> {
438444
const releaseLock = await this.#mutex.acquire();
439445
const { allTokens, allIgnoredTokens, allDetectedTokens } = this.state;
@@ -473,7 +479,7 @@ export class TokensController extends BaseController<
473479
isERC721,
474480
aggregators: formatAggregatorNames(tokenMetadata?.aggregators ?? []),
475481
name,
476-
...(tokenMetadata?.rwaData && { rwaData: tokenMetadata.rwaData }),
482+
...(rwaData !== undefined && { rwaData }),
477483
};
478484
const previousIndex = newTokens.findIndex(
479485
(token) => token.address.toLowerCase() === address.toLowerCase(),
@@ -986,7 +992,7 @@ export class TokensController extends BaseController<
986992

987993
await this.#requestApproval(suggestedAssetMeta);
988994

989-
const { address, symbol, decimals, name, image } = asset;
995+
const { address, symbol, decimals, name, image, rwaData } = asset;
990996
await this.addToken({
991997
address,
992998
symbol,
@@ -995,6 +1001,7 @@ export class TokensController extends BaseController<
9951001
image,
9961002
interactingAddress: suggestedAssetMeta.interactingAddress,
9971003
networkClientId,
1004+
rwaData,
9981005
});
9991006
}
10001007

0 commit comments

Comments
 (0)