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

refactor(on-ramp): refactor quotes screen #6615

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9ae6d6c
refactor(on-ramp): refactor quotes screen
wachunei May 29, 2023
8589dea
feature(on-ramp): add new quote component
wachunei May 29, 2023
4d052d1
chore(on-ramp): upgrade on-ramp-sdk to v1.20.2
wachunei Jun 5, 2023
e3fb3ff
refactor(on-ramp): use reanimated for quotes loading animation
wachunei Jun 5, 2023
369b778
test(on-ramp): add quotes view initial tests
wachunei Jun 5, 2023
378b226
test(on-ramp): add quote buy button press test
wachunei Jun 15, 2023
1dd5d72
test(on-ramp): add quote buy button press test with in-app browser
wachunei Jun 15, 2023
3c8a93a
chore(on-ramp): add TODO for pending change
wachunei Jun 15, 2023
b833156
test(on-ramp): add quote screen cancel test
wachunei Jun 16, 2023
29a8f65
refactor(on-ramp): remove unnecessary casting of event param
wachunei Jun 16, 2023
35970bf
test(on-ramp): fix quote screen cancel test
wachunei Jun 16, 2023
3985b33
refactor(on-ramp): move quotes screen timer to a component
wachunei Jun 16, 2023
0e5abf6
test(on-ramp): add information modal test
wachunei Jun 16, 2023
1f878e3
refactor(on-ramp): use ?? instead of ||
wachunei Jun 16, 2023
52cf196
refactor(on-ramp): use ?? instead of ||
wachunei Jun 16, 2023
6b6432b
refactor(on-ramp): remove unnecessary casting of event param
wachunei Jun 16, 2023
54c7e7c
test(on-ramp): add Timer and LoadingQuotes components test
wachunei Jun 16, 2023
319205c
chore(on-ramp): upgrade on-ramp-sdk to v1.22.0
wachunei Jun 22, 2023
d610d2e
refactor(on-ramp): use apple pay correct variable
wachunei Jun 22, 2023
7e3ce17
chore(on-ramp): upgrade on-ramp-sdk to v1.22.0
wachunei Jun 22, 2023
9e758fa
feat(on-ramp): add staging label to quote button
wachunei Jun 22, 2023
98c306a
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jun 22, 2023
53a1afa
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jul 4, 2023
13db0a3
chore(on-ramp): update snapshots
wachunei Jul 4, 2023
d7d6d69
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jul 10, 2023
d91d495
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jul 11, 2023
a5ce956
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jul 11, 2023
9d54f94
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jul 13, 2023
46ea5fd
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jul 13, 2023
1d29673
Merge branch 'main' into feature/onramp-quotes-fiat-rate
wachunei Jul 13, 2023
eefd19f
Merge branch 'main' into feature/onramp-quotes-fiat-rate
sethkfman Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { FiatOnRampSDKProvider } from '../../UI/FiatOnRampAggregator/sdk';
import GetStarted from '../../../components/UI/FiatOnRampAggregator/Views/GetStarted';
import PaymentMethods from '../../UI/FiatOnRampAggregator/Views/PaymentMethods/PaymentMethods';
import AmountToBuy from '../../../components/UI/FiatOnRampAggregator/Views/AmountToBuy';
import GetQuotes from '../../../components/UI/FiatOnRampAggregator/Views/GetQuotes';
import Quotes from '../../../components/UI/FiatOnRampAggregator/Views/Quotes';
import CheckoutWebView from '../../UI/FiatOnRampAggregator/Views/Checkout';
import OnRampSettings from '../../UI/FiatOnRampAggregator/Views/Settings';
import OnrampAddActivationKey from '../../UI/FiatOnRampAggregator/Views/Settings/AddActivationKey';
Expand Down Expand Up @@ -547,8 +547,8 @@ const FiatOnRampAggregator = () => (
component={AmountToBuy}
/>
<Stack.Screen
name={Routes.FIAT_ON_RAMP_AGGREGATOR.GET_QUOTES}
component={GetQuotes}
name={Routes.FIAT_ON_RAMP_AGGREGATOR.QUOTES}
component={Quotes}
/>
<Stack.Screen
name={Routes.FIAT_ON_RAMP_AGGREGATOR.CHECKOUT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import Routes from '../../../../constants/navigation/Routes';
import { Colors } from '../../../../util/theme/models';
import { NATIVE_ADDRESS } from '../../../../constants/on-ramp';
import { formatAmount } from '../utils';
import { createGetQuotesNavDetails } from './GetQuotes';
import { createQuotesNavDetails } from './Quotes/Quotes';
import { Region } from '../types';

// TODO: Convert into typescript and correctly type
Expand Down Expand Up @@ -518,7 +518,7 @@ const AmountToBuy = () => {
const handleGetQuotePress = useCallback(() => {
if (selectedAsset && currentFiatCurrency) {
navigation.navigate(
...createGetQuotesNavDetails({
...createQuotesNavDetails({
amount: amountNumber,
asset: selectedAsset,
fiatCurrency: currentFiatCurrency,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import Row from '../../components/Row';
import SkeletonQuote from '../../components/SkeletonQuote';

function LoadingQuotes() {
return (
<>
<Row first>
<SkeletonQuote />
</Row>
<Row>
<SkeletonQuote collapsed />
</Row>
<Row>
<SkeletonQuote collapsed />
</Row>
</>
);
}
export default LoadingQuotes;
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
/* eslint-disable import/prefer-default-export */

import { QuoteError, QuoteResponse } from '@consensys/on-ramp-sdk';
import { DeepPartial } from './Quotes.types';

export const mockQuotesData = [
{
provider: {
id: '/providers/banxa-staging',
name: 'Banxa (Staging)',
description:
"Per Banxa: “Established from 2014, Banxa is the world's first publicly listed Financial technology platform, powering a world-leading fiat to crypto gateway solution for customers to buy, sell and trade digital assets. Banxa's payment infrastructure offers online payment services across multiple currencies, crypto, and payment types from card to local bank transfers. Banxa now supports over 130+ countries and more than 80 currencies.”",
hqAddress: '2/6 Gwynne St, Cremorne VIC 3121, Australia',
links: [
{
name: 'Homepage',
url: 'https://banxa.com/',
},
{
name: 'Terms of service',
url: 'https://banxa.com/wp-content/uploads/2022/10/Customer-Terms-and-Conditions-1-July-2022.pdf',
},
],
logos: {
light:
'https://on-ramp.dev-api.cx.metamask.io/assets/providers/banxa_light.png',
dark: 'https://on-ramp.dev-api.cx.metamask.io/assets/providers/banxa_dark.png',
height: 24,
width: 65,
},
features: {
buy: {
userAgent: null,
padCustomOrderId: false,
orderCustomId: '',
browser: 'APP_BROWSER',
orderCustomIdRequired: false,
orderCustomIdExpiration: null,
orderCustomIdSeparator: null,
orderCustomIdPrefixes: ['c-', ''],
supportedByBackend: true,
redirection: 'JSON_REDIRECTION',
},
quotes: {
enabled: false,
supportedByBackend: false,
},
},
},
crypto: {
id: '/currencies/crypto/1/eth',
idv2: '/currencies/crypto/1/0x0000000000000000000000000000000000000000',
network: {
active: true,
chainId: 1,
chainName: 'Ethereum Mainnet',
shortName: 'Ethereum',
},
logo: 'https://token.metaswap.codefi.network/assets/nativeCurrencyLogos/ethereum.svg',
decimals: 18,
address: '0x0000000000000000000000000000000000000000',
symbol: 'ETH',
name: 'Ethereum',
},
cryptoId: '/currencies/crypto/1/eth',
fiat: {
id: '/currencies/fiat/aud',
symbol: 'AUD',
name: 'Australian Dollar',
decimals: 2,
denomSymbol: '$',
},
fiatId: '/currencies/fiat/aud',
networkFee: 0,
providerFee: 1.07,
extraFee: 0,
amountIn: 50,
amountOut: 0.017142,
paymentMethod: 'debit-credit-card',
receiver: '0x1',
isNativeApplePay: false,
exchangeRate: 2854.3927196359814,
error: false,
amountOutInFiat: 46.97353692000001,
},
{
crypto: {
id: '/currencies/crypto/1/eth',
idv2: '/currencies/crypto/1/0x0000000000000000000000000000000000000000',
network: {
active: true,
chainId: 1,
chainName: 'Ethereum Mainnet',
shortName: 'Ethereum',
},
logo: 'https://token.metaswap.codefi.network/assets/nativeCurrencyLogos/ethereum.svg',
decimals: 18,
address: '0x0000000000000000000000000000000000000000',
symbol: 'ETH',
name: 'Ethereum',
},
fiat: {
id: '/currencies/fiat/aud',
symbol: 'AUD',
name: 'Australian Dollar',
decimals: 2,
denomSymbol: '$',
},
amountIn: 50,
amountOut: 0.0162,
networkFee: 2.64,
providerFee: 1.8399999999999999,
provider: {
id: '/providers/moonpay-staging',
name: 'MoonPay (Staging)',
environmentType: 'STAGING',
description:
'Per MoonPay: “MoonPay provides a smooth experience for converting between fiat currencies and cryptocurrencies. Easily top-up with ETH, BNB and more directly in your MetaMask wallet via MoonPay using all major payment methods including debit and credit card, local bank transfers, Apple Pay, Google Pay, and Samsung Pay. MoonPay is active in more than 160 countries and is trusted by 250+ leading wallets, websites, and applications.”',
hqAddress: '8 The Green, Dover, DE, 19901, USA',
links: [
{
name: 'Homepage',
url: 'https://www.moonpay.com/',
},
{
name: 'Privacy Policy',
url: 'https://www.moonpay.com/legal/privacy_policy',
},
{
name: 'Support',
url: 'https://support.moonpay.com/hc/en-gb/categories/360001595097-Customer-Support-Help-Center',
},
],
logos: {
light:
'https://on-ramp.dev-api.cx.metamask.io/assets/providers/moonpay_light.png',
dark: 'https://on-ramp.dev-api.cx.metamask.io/assets/providers/moonpay_dark.png',
height: 24,
width: 88,
},
features: {
buy: {
enabled: true,
userAgent: null,
padCustomOrderId: false,
orderCustomId: 'GUID',
orderCustomIdRequired: false,
orderCustomIdPrefixes: ['c-'],
browser: 'APP_BROWSER',
supportedByBackend: true,
redirection: 'JSON_REDIRECTION',
},
quotes: {
enabled: true,
supportedByBackend: false,
},
sell: {
enabled: true,
},
sellQuotes: {
enabled: true,
},
},
},
exchangeRate: 2809.8765432098767,
error: false,
amountOutInFiat: 44.392212,
},
{
crypto: {
id: '/currencies/crypto/1/eth',
idv2: '/currencies/crypto/1/0x0000000000000000000000000000000000000000',
network: {
active: true,
chainId: 1,
chainName: 'Ethereum Mainnet',
shortName: 'Ethereum',
},
logo: 'https://token.metaswap.codefi.network/assets/nativeCurrencyLogos/ethereum.svg',
decimals: 18,
address: '0x0000000000000000000000000000000000000000',
symbol: 'ETH',
name: 'Ethereum',
},
fiat: {
id: '/currencies/fiat/aud',
symbol: 'AUD',
name: 'Australian Dollar',
decimals: 2,
denomSymbol: '$',
},
amountIn: 50,
amountOut: 0.01590613,
providerFee: 5.76,
networkFee: 0.5,
provider: {
id: '/providers/transak-staging',
name: 'Transak (Staging)',
environmentType: 'STAGING',
description:
'Per Transak: “The fastest and securest way to buy 100+ cryptocurrencies on 75+ blockchains. Pay via Apple Pay, UPI, bank transfer or use your debit or credit card. Trusted by 2+ million global users. Transak empowers wallets, gaming, DeFi, NFTs, Exchanges, and DAOs across 125+ countries.”',
hqAddress:
'35 Shearing Street, Bury St. Edmunds, IP32 6FE, United Kingdom',
links: [
{
name: 'Homepage',
url: 'https://www.transak.com/',
},
{
name: 'Privacy Policy',
url: 'https://www.notion.so/Privacy-Policy-e7f23fb15ece4cf5b0586f9629e08b3f',
},
{
name: 'Support',
url: 'https://support.transak.com/hc/en-us',
},
],
logos: {
light:
'https://on-ramp.dev-api.cx.metamask.io/assets/providers/transak_light.png',
dark: 'https://on-ramp.dev-api.cx.metamask.io/assets/providers/transak_dark.png',
height: 24,
width: 90,
},
features: {
buy: {
enabled: true,
userAgent: null,
padCustomOrderId: false,
orderCustomId: '',
orderCustomIdRequired: false,
orderCustomIdPrefixes: [],
browser: 'APP_BROWSER',
supportedByBackend: false,
redirection: 'HTTP_REDIRECTION',
},
quotes: {
enabled: true,
supportedByBackend: false,
},
},
},
exchangeRate: 2749.8832211229255,
error: true,
amountOutInFiat: 43.586931793800005,
},
] as unknown as (DeepPartial<QuoteResponse> | DeepPartial<QuoteError>)[];
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { StyleSheet } from 'react-native';
import { Theme } from '../../../../../util/theme/models';

const styleSheet = (params: { theme: Theme }) => {
const { theme } = params;
const { colors } = theme;
return StyleSheet.create({
timerWrapper: {
backgroundColor: colors.background.alternative,
borderRadius: 20,
marginBottom: 8,
paddingVertical: 4,
paddingHorizontal: 15,
flexDirection: 'row',
alignItems: 'center',
},
timer: {
fontVariant: ['tabular-nums'],
},
timerHiglight: {
color: colors.error.default,
},
topBorder: {
height: 1,
width: '100%',
backgroundColor: colors.border.default,
},
withoutTopPadding: {
paddingTop: 0,
},
withoutTopMargin: {
marginTop: 0,
},
withoutVerticalPadding: {
paddingVertical: 0,
},
});
};

export default styleSheet;
Loading
Loading