Skip to content

Commit 7c4c07f

Browse files
committed
feat: move set modal state submitting to callback
1 parent 6cfc670 commit 7c4c07f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

features/adjustment/repay/hooks/use-burn.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,28 @@ export const useBurn = (onMutate = () => {}) => {
5555
to: activeVault.owner,
5656
});
5757
const needsAllowance = allowance < amount;
58-
59-
setModalState({ step: SubmitStepEnum.confirming });
60-
6158
if (needsAllowance) {
59+
setModalState({ step: SubmitStepEnum.confirming });
60+
6261
const receipt = await tokenContract.approve({
6362
amount: maxUint256,
6463
to: activeVault.owner,
64+
callback: async (props) => {
65+
if (props.stage === 'receipt') {
66+
setModalState({
67+
step: SubmitStepEnum.submitting,
68+
tx: receipt.hash,
69+
});
70+
}
71+
},
6572
});
6673

67-
setModalState({ step: SubmitStepEnum.submitting, tx: receipt.hash });
68-
6974
await publicClient.waitForTransactionReceipt({
7075
hash: receipt.hash,
7176
});
7277
}
7378

7479
setModalState({ step: SubmitStepEnum.confirming });
75-
7680
const tx = await writeContractAsync({
7781
abi: dashboardAbi,
7882
address: activeVault.owner,

0 commit comments

Comments
 (0)