-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Previews of tokens #20 #24
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/porter-finance/frontend-ido/FmRjjf1vgT2WX44nM8QFVqqg85Yb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vercel preview looks great! Feel free to merge or address comment
@@ -78,6 +85,29 @@ const BondAction = ({ actionType }: { actionType: BondActions }) => { | |||
setBondsToRedeem(theInput || '0') | |||
} | |||
|
|||
React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts and removing this from the bond file and encapsulating the state in the hook itself? Then doing the format wherever the value is being displayed?
So instead of:
const previewConvert = useCallback(
async (amountToPreview?: TokenAmount | null): Promise<string> => {
if (!tokenContract) {
logger.error('tokenContract is null')
return ''
}
if (!amountToPreview) {
logger.error('missing amount to preview')
return ''
}
const response = await tokenContract
.previewConvertBeforeMaturity(amountToPreview.raw.toString())
.catch((error: Error) => {
logger.debug('Failed to preview token', error)
throw error
})
return response
},
[tokenContract],
)
Something like
const usePreviewConvert = async (amountToPreview?: TokenAmount | null, bondAddress: string): Promise<string> => {
const tokenContract = useBondContract(bondAddress)
const [amount, setAmount] = useState(null)
if (!tokenContract) {
logger.error('tokenContract is null')
}
useEffect(() => {
const previewConvert = async () => {
const number = await tokenContract
.previewConvertBeforeMaturity(amountToPreview.raw.toString())
.catch((error: Error) => {
logger.debug('Failed to preview token', error)
throw error
})
setAmount(number)
}
previewConvert()
}, [amountToPreview, tokenContract])
return amount
)
}
We could also leave cleanup tasks like this to later if you think that makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not be worth changing now if we start using that multicall thing namaskar mentioned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah will check this again after multicall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
closes #5
commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit f148e4d Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
…26) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * add portfolio page closes #5 * calling hasRole * fix disconnect * add createBond function * submit form values to contract * this should fix routes * fix create bond call * create bond as a hook * fix passing in args * add role loading * add mint & approve * approveAndMint call * add fake bond data for quick creations * holy changes to mint * finish minting * Squashed commit of the following: commit 3e952cc Author: luckyrobot <97241616+luckyrobot@users.noreply.github.com> Date: Sat Mar 26 11:01:01 2022 -0700 Previews of tokens #20 (#24) * upgrade packages * remove documentation pages * fix max supply of convert closes #21 * when logged out on bond page closes #22 * fix showing bond balance * add preview of tokens closes #20 * remove ethers * fix missing paid function * make tokenAmount more clear * make available overflow ellipsis * 27 get price data for collateral token (#28) * add useTokenPrice hook * add working token price hook * linting - why aren't hooks doing this @luckyrobot? * remove apollo add useSwr * use rpl contract if not on mainnet * reload pricing data every 5 seconds * linting - why aren't hooks doing this @luckyrobot? * fix linting and update refresh interval * remove unused code Co-authored-by: bookland <bookland.porter.finance> Co-authored-by: RusseII <bookland@porter.finance>
closes #20