Skip to content

Commit 84658b8

Browse files
authored
Merge pull request #873 from Loopring/activationFix
Activation fix
2 parents 20619c9 + 3e9d92d commit 84658b8

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/core/src/hooks/useractions/useCheckAccStatus.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const useCheckActiveStatus = <C extends FeeInfo>({
4646
chargeFeeTokenList: C[]
4747
checkFeeIsEnough: (props?: { isRequiredAPI: true; intervalTime?: number }) => void
4848
}): { checkActiveStatusProps: CheckActiveStatusProps<C> } => {
49-
const { account } = useAccount()
49+
const { account, updateAccount } = useAccount()
5050
const { status: walletLayer2Status, updateWalletLayer2 } = useWalletLayer2()
5151
// const { chainInfos } = onchainHashInfo.useOnChainInfo();
5252
// const nodeTimer = React.useRef<NodeJS.Timeout | -1>(-1);
@@ -73,6 +73,7 @@ export const useCheckActiveStatus = <C extends FeeInfo>({
7373
setShowActiveAccount({ isShow: true })
7474
}
7575
const onIKnowClick = async () => {
76+
const { account } = store.getState()
7677
const [walletType, coinbaseSW] = await Promise.all([
7778
LoopringAPI?.walletAPI?.getWalletType({
7879
wallet: account.accAddress,
@@ -84,7 +85,7 @@ export const useCheckActiveStatus = <C extends FeeInfo>({
8485
const isActivationSupported =
8586
!walletType?.walletType?.isContract ||
8687
(coinbaseSW && coinbaseSmartWalletChains.includes(defaultNetwork))
87-
if (!isActivationSupported || account._accountIdNotActive === -1 || isFeeNotEnough.isFeeNotEnough) {
88+
if (!isActivationSupported || isFeeNotEnough.isFeeNotEnough) {
8889
setKnow(true)
8990
} else {
9091
goUpdateAccount()
@@ -115,13 +116,17 @@ export const useCheckActiveStatus = <C extends FeeInfo>({
115116
setKnowDisable(false)
116117
}, [chargeFeeTokenList])
117118

119+
const checkFeeIsEnoughInterval = React.useRef<NodeJS.Timeout | -1>(-1)
120+
118121
React.useEffect(() => {
119122
if (walletLayer2Callback && walletLayer2Status === SagaStatus.UNSET) {
120123
walletLayer2Callback()
121124
checkFeeIsEnough()
122125
}
126+
123127
}, [walletLayer2Status])
124128

129+
125130
const init = React.useCallback(async () => {
126131
setKnowDisable(true)
127132
try {
@@ -142,6 +147,17 @@ export const useCheckActiveStatus = <C extends FeeInfo>({
142147
if (isShowAccount.isShow && isShowAccount.step === AccountStep.CheckingActive) {
143148
init()
144149
setKnow(false)
150+
checkFeeIsEnoughInterval.current = setInterval(() => {
151+
updateWalletLayer2()
152+
walletLayer2Callback()
153+
checkFeeIsEnough()
154+
updateAccount({})
155+
}, 10 * 1000)
156+
}
157+
return () => {
158+
if (checkFeeIsEnoughInterval.current !== -1) {
159+
clearInterval(checkFeeIsEnoughInterval.current)
160+
}
145161
}
146162
}, [isShowAccount.step, isShowAccount.isShow])
147163

0 commit comments

Comments
 (0)