Skip to content

Commit b158f28

Browse files
authored
Fix the race condition by putting the setters at the end of the function (#1091)
1 parent 9d98c71 commit b158f28

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

governance/xc_admin/packages/xc_admin_frontend/hooks/useMultisig.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,39 +101,31 @@ export const useMultisig = (): MultisigHookData => {
101101
wallet: new NodeWallet(new Keypair()),
102102
})
103103
if (cancelled) return
104-
setUpgradeMultisigAccount(
105-
await readOnlySquads.getMultisig(UPGRADE_MULTISIG[multisigCluster])
104+
const upgradeMultisigAccount = await readOnlySquads.getMultisig(
105+
UPGRADE_MULTISIG[multisigCluster]
106+
)
107+
108+
if (cancelled) return
109+
const priceFeedMultisigAccount = await readOnlySquads.getMultisig(
110+
PRICE_FEED_MULTISIG[multisigCluster]
106111
)
107-
try {
108-
if (cancelled) return
109-
setPriceFeedMultisigAccount(
110-
await readOnlySquads.getMultisig(
111-
PRICE_FEED_MULTISIG[multisigCluster]
112-
)
113-
)
114-
} catch (e) {
115-
console.error(e)
116-
setPriceFeedMultisigAccount(undefined)
117-
}
118112

119113
if (cancelled) return
120114
const upgradeProposals = await getSortedProposals(
121115
readOnlySquads,
122116
UPGRADE_MULTISIG[multisigCluster]
123117
)
118+
119+
if (cancelled) return
120+
const sortedPriceFeedMultisigProposals = await getSortedProposals(
121+
readOnlySquads,
122+
PRICE_FEED_MULTISIG[multisigCluster]
123+
)
124+
125+
setUpgradeMultisigAccount(upgradeMultisigAccount)
126+
setPriceFeedMultisigAccount(priceFeedMultisigAccount)
124127
setUpgradeMultisigProposals(upgradeProposals)
125-
try {
126-
if (cancelled) return
127-
const sortedPriceFeedMultisigProposals = await getSortedProposals(
128-
readOnlySquads,
129-
PRICE_FEED_MULTISIG[multisigCluster]
130-
)
131-
setPriceFeedMultisigProposals(sortedPriceFeedMultisigProposals)
132-
} catch (e) {
133-
console.error(e)
134-
setAllProposalsIxsParsed([])
135-
setPriceFeedMultisigProposals([])
136-
}
128+
setPriceFeedMultisigProposals(sortedPriceFeedMultisigProposals)
137129

138130
setIsLoading(false)
139131
} catch (e) {

0 commit comments

Comments
 (0)