-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOV-3077: update claim button logic (#2575)
* SOV-3077: update claim button logic * chore: update text
- Loading branch information
1 parent
8eeb948
commit a8ad150
Showing
4 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/app/pages/RewardPage/components/ClaimForms/BaseClaimForm/hooks/useGetFilteredDates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { contractReader } from 'utils/sovryn/contract-reader'; | ||
|
||
const useGetFilteredDates = (vestingAddresses: string[]) => { | ||
const [filteredDates, setFilteredDates] = useState<string[]>([]); | ||
|
||
useEffect(() => { | ||
const fetchDatesForAddresses = async () => { | ||
const datesArray: string[] = []; | ||
|
||
for (const address of vestingAddresses) { | ||
try { | ||
const res = await contractReader.call('staking', 'getStakes', [ | ||
address, | ||
]); | ||
const dates = res['dates']; | ||
datesArray.push(...dates); | ||
} catch (error) { | ||
console.error('Error fetching dates for address', address, error); | ||
} | ||
} | ||
setFilteredDates(datesArray); | ||
}; | ||
|
||
fetchDatesForAddresses(); | ||
}, [vestingAddresses]); | ||
|
||
return filteredDates; | ||
}; | ||
|
||
export default useGetFilteredDates; |
28 changes: 28 additions & 0 deletions
28
src/app/pages/RewardPage/components/ClaimForms/BaseClaimForm/hooks/useGetVestingAddresses.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useListOfUserVestings } from 'app/components/UserAssets/Vesting/useListOfUserVestings'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
const useGetVestingAddresses = () => { | ||
const { loading, items } = useListOfUserVestings(); | ||
|
||
const [vestingAddresses, setVestingAddresses] = useState<string[]>([]); | ||
|
||
useEffect(() => { | ||
const getVestingContractAddresses = async () => { | ||
try { | ||
const vestingContracts: string[] = await Promise.all( | ||
items.map(async item => item.vestingContract), | ||
); | ||
setVestingAddresses(vestingContracts); | ||
} catch (error) { | ||
console.error('Error fetching vesting contract addresses:', error); | ||
} | ||
}; | ||
if (!loading) { | ||
getVestingContractAddresses(); | ||
} | ||
}, [items, loading]); | ||
|
||
return vestingAddresses; | ||
}; | ||
|
||
export default useGetVestingAddresses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters