diff --git a/packages/common/src/chaindata/queries/Identity.ts b/packages/common/src/chaindata/queries/Identity.ts index 72fd12f78..f3ae63136 100644 --- a/packages/common/src/chaindata/queries/Identity.ts +++ b/packages/common/src/chaindata/queries/Identity.ts @@ -88,6 +88,23 @@ export const getFormattedIdentity = async ( const identityInfo = await chaindata.api?.derive.accounts.identity(addr); if (!identityInfo) return null; + const hasSubs = await chaindata.api?.query.identity.subsOf(addr); + if (hasSubs && hasSubs[1].length > 0) { + for (const subaccountAddress of hasSubs[1]) { + const subAccountIdentity = + await chaindata.api?.derive.accounts.identity( + subaccountAddress.toString(), + ); + if (subAccountIdentity) { + const subAccount: { name: string; address: string } = { + name: subAccountIdentity.display || "", + address: subaccountAddress.toString(), + }; + subAccounts.push(subAccount); + } + } + } + const { display, email, diff --git a/packages/common/test/chaindata/chaindata.int.test.ts b/packages/common/test/chaindata/chaindata.int.test.ts index a66768a62..eaed686e4 100644 --- a/packages/common/test/chaindata/chaindata.int.test.ts +++ b/packages/common/test/chaindata/chaindata.int.test.ts @@ -340,7 +340,7 @@ describe("ChainData Integration Tests", () => { "should fetch identity", async () => { const getIdentity = await chainData.getIdentity( - "J4hAvZoHCviZSoPHoSwLida8cEkZR1NXJcGrcfx9saHTk7D", + "DBfT2GUqHX89afMhTzGCCbAc44zX33d4XySWX2qAPxZ35KE", ); expect(getIdentity).toBeDefined(); }, @@ -351,7 +351,7 @@ describe("ChainData Integration Tests", () => { "should fetch formatted identity", async () => { const identity = await chainData.getFormattedIdentity( - "J4hAvZoHCviZSoPHoSwLida8cEkZR1NXJcGrcfx9saHTk7D", + "CbaNLeJQ8e8aCJMTLa9euDKuTDmnT5oPmGFt4AmuvXmYFGN", ); expect(identity).toBeDefined(); },