Skip to content

Commit bed7bee

Browse files
committed
cloud_functions: improve computeGuardianSetInfo
1 parent 3bdc8af commit bed7bee

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

cloud_functions/src/computeGuardianSetInfo.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,22 @@ export async function computeGuardianSetInfo(req: any, res: any) {
3131

3232
async function getGuardianSetInfoByChain(): Promise<GuardianSetInfoByChain> {
3333
let infosByChain: GuardianSetInfoByChain = {};
34-
for (const chain of chains) {
35-
const contract = contracts.coreBridge.get('Mainnet', chain); // Only support Mainnet for now
36-
if (!contract) {
37-
console.log(`No contract found for ${chain}`);
38-
continue;
34+
const infos = await Promise.all(
35+
chains.map((chain) => {
36+
const contract = contracts.coreBridge.get('Mainnet', chain); // Only support Mainnet for now
37+
if (!contract) {
38+
console.log(`No contract found for ${chain}`);
39+
return Promise.resolve(null);
40+
}
41+
return fetchGuardianSetInfo(chain, contract);
42+
})
43+
);
44+
for (let idx = 0; idx < chains.length; idx++) {
45+
const chain = chains[idx];
46+
const info = infos[idx];
47+
if (info) {
48+
infosByChain[chain] = info;
3949
}
40-
const info: GuardianSetInfo = await fetchGuardianSetInfo(chain, contract);
41-
infosByChain[chain] = info;
4250
}
4351
console.log('Guardian set info:', infosByChain);
4452
return infosByChain;

0 commit comments

Comments
 (0)