@@ -75,58 +75,60 @@ export const walletApi = apiWithTag.injectEndpoints({
7575 throw new Error ( 'List of the wallets is not defined' ) ;
7676 }
7777
78- return {
79- data : await Promise . all (
80- wallets . map ( async ( wallet : Wallet ) => {
81- const { type } = wallet ;
82- const meta : any = { } ;
83- if ( [ WalletType . CAT , WalletType . CRCAT ] . includes ( type ) ) {
84- // get CAT asset
85- const { data : assetData , error : assetError } = await fetchWithBQ ( {
86- command : 'getAssetId' ,
87- service : CAT ,
88- args : { walletId : wallet . id } ,
89- } ) ;
78+ const allWallets = await Promise . all (
79+ wallets . map ( async ( wallet : Wallet ) => {
80+ const { type } = wallet ;
81+ const meta : any = { } ;
82+ if ( [ WalletType . CAT , WalletType . RCAT , WalletType . CRCAT ] . includes ( type ) ) {
83+ // get CAT asset
84+ const { data : assetData , error : assetError } = await fetchWithBQ ( {
85+ command : 'getAssetId' ,
86+ service : CAT ,
87+ args : { walletId : wallet . id } ,
88+ } ) ;
9089
91- if ( assetError ) {
92- throw assetError as Error ;
93- }
90+ if ( assetError ) {
91+ throw assetError as Error ;
92+ }
9493
95- meta . assetId = assetData . assetId ;
94+ meta . assetId = assetData . assetId ;
9695
97- // get CAT name
98- const { data : nameData , error : nameError } = await fetchWithBQ ( {
99- command : 'getName' ,
100- service : CAT ,
101- args : { walletId : wallet . id } ,
102- } ) ;
103-
104- if ( nameError ) {
105- throw nameError as Error ;
106- }
96+ // get CAT name
97+ const { data : nameData , error : nameError } = await fetchWithBQ ( {
98+ command : 'getName' ,
99+ service : CAT ,
100+ args : { walletId : wallet . id } ,
101+ } ) ;
107102
108- meta . name = nameData . name ;
109- } else if ( type === WalletType . NFT ) {
110- // get DID assigned to the NFT Wallet (if any)
111- const { data : didData , error : didError } = await fetchWithBQ ( {
112- command : 'getNftWalletDid' ,
113- service : NFT ,
114- args : { walletId : wallet . id } ,
115- } ) ;
103+ if ( nameError ) {
104+ throw nameError as Error ;
105+ }
116106
117- if ( didError ) {
118- throw didError as Error ;
119- }
107+ meta . name = nameData . name ;
108+ } else if ( type === WalletType . NFT ) {
109+ // get DID assigned to the NFT Wallet (if any)
110+ const { data : didData , error : didError } = await fetchWithBQ ( {
111+ command : 'getNftWalletDid' ,
112+ service : NFT ,
113+ args : { walletId : wallet . id } ,
114+ } ) ;
120115
121- meta . did = didData . didId ;
116+ if ( didError ) {
117+ throw didError as Error ;
122118 }
123119
124- return {
125- ...wallet ,
126- meta,
127- } ;
128- } ) ,
129- ) ,
120+ meta . did = didData . didId ;
121+ }
122+
123+ return {
124+ ...wallet ,
125+ meta,
126+ } ;
127+ } ) ,
128+ ) ;
129+
130+ return {
131+ data : allWallets ,
130132 } ;
131133 } catch ( error ) {
132134 return {
0 commit comments