Skip to content

Commit

Permalink
feat: add new chains for fiat onramp (#7476)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 3b2b83f</samp>

### Summary
🌐💵♻️

<!--
1. 🌐 - This emoji represents the addition of more chains to the
`SUPPORTED_CHAINS` array and the restructuring of the supported tokens
for each on-ramp provider. It conveys the idea of expanding the buy
crypto feature to more networks and currencies.
2. 💵 - This emoji represents the change in the `onFieldAInput` function
call to use the `code` of the base currency. It conveys the idea of
updating the input field with the appropriate default amount based on
the fiat currency selected by the user.
3. ♻️ - This emoji represents the refactoring and improvement of the
`FiatOnRampModal` component and the `calculateDefaultAmount` function.
It conveys the idea of cleaning up and optimizing the code for better
performance and readability.
-->
The pull request enhances the buy crypto feature by adding support for
more chains and tokens, refactoring the code to use a common
`supportedTokenMap` object, and improving the default amount calculation
for fiat currencies. It affects the files `FiatOnRampModal.tsx`,
`hooks.ts`, `constants.ts`, and `BuyCryptoForm.tsx` in the
`apps/web/src` directory.

> _Buy crypto feature_
> _`SUPPORTED_CHAINS` expands_
> _Winter of scaling_

### Walkthrough
* Enable buy crypto feature for more chains and tokens by adding
`ChainId.ZKSYNC` and `ChainId.ARBITRUM_ONE` to `SUPPORTED_CHAINS` array
and restructuring supported tokens for each on-ramp provider into
separate arrays and a `supportedTokenMap` object in `constants.ts`
([link](https://github.com/pancakeswap/pancake-frontend/pull/7476/files?diff=unified&w=0#diff-51b519af02f51d8fd66dfd13f06ed8e1b3b6ac5373780b862109543ecd77c896L3-R45))
* Use `supportedTokenMap` object to dynamically pass the supported
tokens for each chain to the `fetchMoonPaySignedUrl` and
`fetchMercuryoSignedUrl` functions in `FiatOnRampModal.tsx`
([link](https://github.com/pancakeswap/pancake-frontend/pull/7476/files?diff=unified&w=0#diff-ec1dc15e7eaff4dffe6bf7d046f9b9f4c26a27a63089eee9af39f63659bb0905L125-R122),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7476/files?diff=unified&w=0#diff-ec1dc15e7eaff4dffe6bf7d046f9b9f4c26a27a63089eee9af39f63659bb0905L286-R283))
* Update the `typedValue` parameter for the `replaceBuyCryptoState`
action in `hooks.ts` and the `onFieldAInput` function call in
`BuyCryptoForm.tsx` to use the modified `calculateDefaultAmount`
function with the fiat currency code parsed from the URL or the base
currency
([link](https://github.com/pancakeswap/pancake-frontend/pull/7476/files?diff=unified&w=0#diff-62400b856d722556576b04bcbb9ff801cfaf142737eec302b955b8ab04a2c1f7L314-R340),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7476/files?diff=unified&w=0#diff-882eb9c5537b615b2172ba5b24afa7dcb5bf9f929276f64a0f19157ace7c9c11L73-R77))
* Import `ChainId` and `Box` components from `@pancakeswap/sdk` and
`@pancakeswap/uikit` packages respectively in `FiatOnRampModal.tsx` to
use the `ChainId` enum for identifying different chains and the `Box`
component for styling the modal
([link](https://github.com/pancakeswap/pancake-frontend/pull/7476/files?diff=unified&w=0#diff-ec1dc15e7eaff4dffe6bf7d046f9b9f4c26a27a63089eee9af39f63659bb0905L2-R5))
* Reorder and remove some unused imports in `FiatOnRampModal.tsx` to
improve the readability and maintainability of the code
([link](https://github.com/pancakeswap/pancake-frontend/pull/7476/files?diff=unified&w=0#diff-ec1dc15e7eaff4dffe6bf7d046f9b9f4c26a27a63089eee9af39f63659bb0905L12-R30))
  • Loading branch information
ChefBingbong authored Aug 17, 2023
1 parent 2e4593b commit 358994e
Show file tree
Hide file tree
Showing 26 changed files with 328 additions and 235 deletions.
1 change: 0 additions & 1 deletion apps/web/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
NEXT_PUBLIC_MM_API_URL=https://linked-pool.pancakeswap.com/quote-service
NEXT_PUBLIC_QUOTING_API=https://swap-quoting.pancakeswap.com/quoting-service
MOONPAY_API="https://api.moonpay.com"
MOONPAY_PUBLISHABLE_KEY="pk_live_Ch5fat39X8NvMZwih2k7hK4sDrKanSPz"
1 change: 0 additions & 1 deletion apps/web/public/images/AUD.svg

This file was deleted.

This file was deleted.

29 changes: 29 additions & 0 deletions apps/web/public/images/pocket-watch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

1 comment on commit 358994e

@vercel
Copy link

@vercel vercel bot commented on 358994e Aug 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

uikit – ./packages/uikit

uikit.pancake.run
uikit-git-develop.pancake.run

Please sign in to comment.