Skip to content

Commit

Permalink
refactor(ramp): amount to buy rename to build quote + hooks (#7227)
Browse files Browse the repository at this point in the history
<!--
Thanks for your contribution!

Please ensure that any applicable requirements below are satisfied
before submitting this pull request. This will help ensure a quick and
efficient review cycle.
-->

**Development & PR Process**
1. Follow MetaMask [Mobile Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/coding_guidelines/CODING_GUIDELINES.md)
2. Add `release-xx` label to identify the PR slated for a upcoming
release (will be used in release discussion)
3. Add `needs-dev-review` label when work is completed
4. Add the appropiate QA label when dev review is completed
    - `needs-qa`: PR requires manual QA.
- `No QA/E2E only`: PR does not require any manual QA effort. Prior to
merging, ensure that you have successful end-to-end test runs in
Bitrise.
- `Spot check on release build`: PR does not require feature QA but
needs non-automated verification. In the description section, provide
test scenarios. Add screenshots, and or recordings of what was tested.
5. Add `QA Passed` label when QA has signed off (Only required if the PR
was labeled with `needs-qa`)
6. Add your team's label, i.e. label starting with `team-` (or
`external-contributor` label if your not a MetaMask employee)

**Description**

This PR renames the "Amount To Buy" View to "Build Quote". It also
extracts the logic for crypto currencies, fiat currencies and limits
into hooks. These hooks in the future will accept a ramp type value,
either buy or sell.

**Screenshots/Recordings**

~~_If applicable, add screenshots and/or recordings to visualize the
before and after of your change_~~

**Issue**

fixes #???

**Checklist**

* [ ] There is a related GitHub issue
* [ ] Tests are included if applicable
* [ ] Any added code is fully documented

---------

Co-authored-by: Pedro Pablo Aste Kompen <[email protected]>
  • Loading branch information
georgeweiler and wachunei authored Oct 3, 2023
1 parent 3ddefb7 commit 6f56b2d
Show file tree
Hide file tree
Showing 17 changed files with 12,110 additions and 293 deletions.
21 changes: 21 additions & 0 deletions app/components/Base/Keypad/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,26 @@ function KeypadComponent({
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress1}
accessibilityRole="button"
accessible
>
1
</Keypad.Button>
<Keypad.Button
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress2}
accessibilityRole="button"
accessible
>
2
</Keypad.Button>
<Keypad.Button
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress3}
accessibilityRole="button"
accessible
>
3
</Keypad.Button>
Expand All @@ -114,20 +120,26 @@ function KeypadComponent({
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress4}
accessibilityRole="button"
accessible
>
4
</Keypad.Button>
<Keypad.Button
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress5}
accessibilityRole="button"
accessible
>
5
</Keypad.Button>
<Keypad.Button
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress6}
accessibilityRole="button"
accessible
>
6
</Keypad.Button>
Expand All @@ -137,20 +149,26 @@ function KeypadComponent({
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress7}
accessibilityRole="button"
accessible
>
7
</Keypad.Button>
<Keypad.Button
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress8}
accessibilityRole="button"
accessible
>
8
</Keypad.Button>
<Keypad.Button
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress9}
accessibilityRole="button"
accessible
>
9
</Keypad.Button>
Expand All @@ -167,10 +185,13 @@ function KeypadComponent({
style={digitButtonStyle}
textStyle={digitTextStyle}
onPress={handleKeypadPress0}
accessibilityRole="button"
accessible
>
0
</Keypad.Button>
<Keypad.DeleteButton
testID="keypad-delete-button"
style={deleteButtonStyle}
icon={deleteIcon}
onPress={handleKeypadPressBack}
Expand Down
4 changes: 2 additions & 2 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import Drawer from '../../UI/Drawer';
import { RampSDKProvider } from '../../UI/Ramp/common/sdk';
import GetStarted from '../../UI/Ramp/buy/Views/GetStarted';
import PaymentMethods from '../../UI/Ramp/buy/Views/PaymentMethods/PaymentMethods';
import AmountToBuy from '../../UI/Ramp/buy/Views/AmountToBuy';
import BuildQuote from '../../UI/Ramp/buy/Views/BuildQuote/BuildQuote';
import Quotes from '../../UI/Ramp/buy/Views/Quotes';
import CheckoutWebView from '../../UI/Ramp/buy/Views/Checkout';
import RampSettings from '../../UI/Ramp/common/Views/Settings';
Expand Down Expand Up @@ -534,7 +534,7 @@ const Ramps = () => (
/>
<Stack.Screen
name={Routes.RAMP.BUY.AMOUNT_TO_BUY}
component={AmountToBuy}
component={BuildQuote}
/>
<Stack.Screen name={Routes.RAMP.BUY.QUOTES} component={Quotes} />
<Stack.Screen
Expand Down
146 changes: 146 additions & 0 deletions app/components/UI/Ramp/buy/Views/BuildQuote/BuildQuote.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import {
Country,
CryptoCurrency,
FiatCurrency,
Payment,
} from '@consensys/on-ramp-sdk';

export const mockCryptoCurrenciesData = [
{
id: '2',
idv2: '3',
network: {},
symbol: 'ETH',
logo: 'some_random_logo_url',
decimals: 8,
address: '0xabc',
name: 'Ethereum',
limits: ['0.001', '8'],
},
{
id: '3',
idv2: '4',
network: {},
symbol: 'UNI',
logo: 'uni_logo_url',
decimals: 8,
address: '0x1a2b3c',
name: 'Uniswap',
limits: ['0.001', '8'],
},
] as CryptoCurrency[];

export const mockFiatCurrenciesData = [
{
id: '2',
symbol: 'USD',
name: 'US Dollar',
decimals: 2,
denomSymbol: '$',
},
{
id: '3',
symbol: 'EUR',
name: 'Euro',
decimals: 2,
denomSymbol: '€',
},
] as FiatCurrency[];

export const mockPaymentMethods = [
{
id: '/payments/credit-debit-card',
paymentType: 'credit-debit-card',
name: 'Credit or Debit Card',
score: 8,
icons: [
{
type: 'materialIcons',
name: 'card',
},
],
logo: {
light: [
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
],
dark: [
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
],
},
disclaimer:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua',
delay: [5, 10],
amountTier: [1, 3],
translation: 'debit-credit-card',
},
{
id: '/payments/apple-pay',
paymentType: 'apple-pay',
name: 'Apple Pay',
score: 6,
icons: [
{
type: 'fontAwesome',
name: 'apple',
},
],
logo: {
light: [
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
],
dark: [
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
],
},
disclaimer: 'Apple credit is not supported.',
delay: [0, 0],
amountTier: [1, 3],
isApplePay: true,
translation: 'mobile_wallet',
},
{
id: '/payments/bank-transfer',
paymentType: 'bank-transfer',
name: 'Super Instant Bank Transfer',
score: 5,
icons: [
{
type: 'materialCommunityIcons',
name: 'bank',
},
],
logo: {
light: [
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
],
dark: [
'https://on-ramp.metafi-dev.codefi.network/assets/[email protected]',
],
},
delay: [0, 0],
amountTier: [3, 3],
supportedCurrency: ['/currencies/fiat/usd'],
translation: 'ACH',
},
] as Partial<Payment>[];

export const mockRegionsData = [
{
currencies: ['/currencies/fiat/clp'],
emoji: 'chile emoji',
id: '/regions/cl',
name: 'Chile',
unsupported: false,
},
{
currencies: ['/currencies/fiat/eur'],
emoji: 'albania emoji',
id: '/regions/al',
name: 'Albania',
unsupported: false,
},
] as Country[];
44 changes: 44 additions & 0 deletions app/components/UI/Ramp/buy/Views/BuildQuote/BuildQuote.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Theme } from '../../../../../../util/theme/models';
import { StyleSheet } from 'react-native';

const styleSheet = (params: { theme: Theme }) => {
const { theme } = params;
const { colors } = theme;

return StyleSheet.create({
viewContainer: {
flex: 1,
},
selectors: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
spacer: {
minWidth: 8,
},
row: {
marginVertical: 5,
},
keypadContainer: {
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
paddingBottom: 50,
backgroundColor: colors.background.alternative,
},
cta: {
paddingTop: 12,
},
flexRow: {
flexDirection: 'row',
},
flagText: {
marginVertical: 3,
marginHorizontal: 0,
},
});
};

export default styleSheet;
Loading

0 comments on commit 6f56b2d

Please sign in to comment.