Skip to content
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

Merged
merged 8 commits into from
Mar 26, 2022
Merged

Previews of tokens #20 #24

merged 8 commits into from
Mar 26, 2022

Conversation

luckyrobot
Copy link

@luckyrobot luckyrobot commented Mar 25, 2022

closes #20

@luckyrobot luckyrobot requested a review from RusseII March 25, 2022 17:34
@vercel
Copy link

vercel bot commented Mar 25, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/porter-finance/frontend-ido/FmRjjf1vgT2WX44nM8QFVqqg85Yb
✅ Preview: https://frontend-ido-git-previews-of-tokens-20-porter-finance.vercel.app

@luckyrobot luckyrobot enabled auto-merge (squash) March 25, 2022 17:46
Copy link
Contributor

@RusseII RusseII left a 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(() => {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

luckyrobot added a commit that referenced this pull request Mar 29, 2022
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
luckyrobot added a commit that referenced this pull request Mar 29, 2022
…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>
@luckyrobot luckyrobot deleted the previews-of-tokens-#20 branch April 20, 2022 12:49
Geczy added a commit that referenced this pull request May 7, 2022
* 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
Geczy added a commit that referenced this pull request May 7, 2022
…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>
Geczy added a commit that referenced this pull request May 7, 2022
* 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
Geczy added a commit that referenced this pull request May 7, 2022
…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>
Geczy added a commit that referenced this pull request May 7, 2022
* 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
Geczy added a commit that referenced this pull request May 7, 2022
…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>
Geczy pushed a commit that referenced this pull request May 7, 2022
* 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
Geczy pushed a commit that referenced this pull request May 7, 2022
…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>
Geczy added a commit that referenced this pull request May 7, 2022
* 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
Geczy added a commit that referenced this pull request May 7, 2022
…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>
Geczy added a commit that referenced this pull request May 7, 2022
…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>
Geczy added a commit that referenced this pull request May 7, 2022
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

previews of tokens
2 participants