diff --git a/packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx b/packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx index a4a60ef0ae..2412f8b2ea 100644 --- a/packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx +++ b/packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx @@ -31,6 +31,7 @@ const DAORecord = ({ }) => { const [t] = useTranslation() const [withdrawValue, setWithdrawValue] = useState('') + const [withdrawingEpoch, setWithdrawingEpoch] = useState('') const [depositEpoch, setDepositEpoch] = useState('') useEffect(() => { @@ -69,7 +70,15 @@ const DAORecord = ({ .catch((err: Error) => { console.error(err) }) - }, [daoData, depositOutPoint]) + + getBlockByNumber(BigInt(blockNumber)) + .then(b => { + setWithdrawingEpoch(b.header.epoch) + }) + .catch((err: Error) => { + console.error(err) + }) + }, [daoData, depositOutPoint, blockNumber]) const interest = BigInt(withdrawValue) - BigInt(capacity) @@ -83,7 +92,8 @@ const DAORecord = ({ } else { const depositEpochInfo = epochParser(depositEpoch) const currentEpochInfo = epochParser(epoch) - const targetEpochNumber = calculateClaimEpochNumber(depositEpochInfo, currentEpochInfo) + const withdrawingEpochInfo = epochParser(withdrawingEpoch) + const targetEpochNumber = calculateClaimEpochNumber(depositEpochInfo, withdrawingEpochInfo) if (targetEpochNumber <= currentEpochInfo.number) { metaInfo = 'Ready' ready = true diff --git a/packages/neuron-ui/src/utils/calculateClaimEpochNumber.ts b/packages/neuron-ui/src/utils/calculateClaimEpochNumber.ts index 5ebadb8e7c..94f6c4a9e8 100644 --- a/packages/neuron-ui/src/utils/calculateClaimEpochNumber.ts +++ b/packages/neuron-ui/src/utils/calculateClaimEpochNumber.ts @@ -6,10 +6,10 @@ interface EpochInfo { length: bigint } -export default (depositEpochInfo: EpochInfo, currentEpochInfo: EpochInfo) => { - let depositedEpochs = currentEpochInfo.number - depositEpochInfo.number - const depositEpochFraction = depositEpochInfo.index * currentEpochInfo.length - const currentEpochFraction = currentEpochInfo.index * depositEpochInfo.length +export default (depositEpochInfo: EpochInfo, withdrawingEpochInfo: EpochInfo) => { + let depositedEpochs = withdrawingEpochInfo.number - depositEpochInfo.number + const depositEpochFraction = depositEpochInfo.index * withdrawingEpochInfo.length + const currentEpochFraction = withdrawingEpochInfo.index * depositEpochInfo.length if (currentEpochFraction > depositEpochFraction) { depositedEpochs += BigInt(1) }