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

feat(wallet) Implement Meld Buy Flow in the FE (uplift to 1.72.x) #26305

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ AndroidWalletPageUI::AndroidWalletPageUI(content::WebUI* web_ui,
kUntrustedLineChartURL + " " + kUntrustedMarketURL + ";");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ImgSrc,
base::JoinString(
{"img-src", "'self'", "chrome://resources",
"chrome://erc-token-images", base::StrCat({"data:", ";"})},
" "));
base::JoinString({"img-src", "'self'", "chrome://resources",
"chrome://erc-token-images", "chrome://image",
base::StrCat({"data:", ";"})},
" "));
source->AddString("braveWalletTrezorBridgeUrl", kUntrustedTrezorURL);
source->AddString("braveWalletNftBridgeUrl", kUntrustedNftURL);
source->AddString("braveWalletLineChartBridgeUrl", kUntrustedLineChartURL);
Expand Down
22 changes: 22 additions & 0 deletions components/brave_wallet/browser/brave_wallet_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,28 @@ inline constexpr webui::LocalizedString kLocalizedStrings[] = {
{"braveWalletBuyWithRamp", IDS_BRAVE_WALLET_BUY_WITH_RAMP},
{"braveWalletSellWithProvider", IDS_BRAVE_WALLET_SELL_WITH_PROVIDER},
{"braveWalletBuyDisclaimer", IDS_BRAVE_WALLET_BUY_DISCLAIMER},
{"braveWalletTransactionsPartner", IDS_BRAVE_WALLET_TRANSACTIONS_PARTNER},
{"braveWalletTransactionPartnerConsent",
IDS_BRAVE_WALLET_TRANSACTION_PARTNER_CONSENT},
{"braveWalletMeldTermsOfUse", IDS_BRAVE_WALLET_MELD_TERMS_OF_USE},
{"braveWalletBestOption", IDS_BRAVE_WALLET_BEST_OPTION},
{"braveWalletExchangeRateWithFees",
IDS_BRAVE_WALLET_EXCHANGE_RATE_WITH_FEES},
{"braveWalletFees", IDS_BRAVE_WALLET_FEES},
{"braveWalletPriceCurrency", IDS_BRAVE_WALLET_PRICE_CURRENCY},
{"braveWalletBuyWithProvider", IDS_BRAVE_WALLET_BUY_WITH_PROVIDER},
{"braveWalletAsset", IDS_BRAVE_WALLET_ASSETS},
{"braveWalletSelected", IDS_BRAVE_WALLET_SELECTED},
{"braveWalletNoAvailableCurrencies",
IDS_BRAVE_WALLET_NO_AVAILABLE_CURRENCIES},
{"braveWalletGettingBestPrices", IDS_BRAVE_WALLET_GETTING_BEST_PRICES},
{"braveWalletBuyAsset", IDS_BRAVE_WALLET_BUY_ASSET},
{"braveWalletNoProviderFound", IDS_BRAVE_WALLET_NO_PROVIDER_FOUND},
{"braveWalletTrySearchingForDifferentAsset",
IDS_BRAVE_WALLET_TRY_SEARCHING_FOR_DIFFERENT_ASSET},
{"braveWalletNoResultsFound", IDS_BRAVE_WALLET_NO_RESULTS_FOUND},
{"braveWalletTryDifferentKeywords",
IDS_BRAVE_WALLET_TRY_DIFFERENT_KEYWORDS},
{"braveWalletBuyWithSardine", IDS_BRAVE_WALLET_BUY_WITH_SARDINE},
{"braveWalletBuyWithTransak", IDS_BRAVE_WALLET_BUY_WITH_TRANSAK},
{"braveWalletBuyWithStripe", IDS_BRAVE_WALLET_BUY_WITH_STRIPE},
Expand Down
27 changes: 26 additions & 1 deletion components/brave_wallet_ui/common/async/__mocks__/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { assert } from 'chrome://resources/js/assert.js'
import type { AnyAction } from 'redux'

// types
import { BraveWallet, CommonNftMetadata } from '../../../constants/types'
import {
BraveWallet,
CommonNftMetadata,
MeldFiatCurrency,
MeldFilter
} from '../../../constants/types'
import { WalletActions } from '../../actions'
import type WalletApiProxy from '../../wallet_api_proxy'

Expand Down Expand Up @@ -562,6 +567,26 @@ export class MockedWalletApiProxy {
})
}

meldIntegrationService: Partial<
InstanceType<typeof BraveWallet.MeldIntegrationServiceInterface>
> = {
getFiatCurrencies: async (
filter: MeldFilter
): Promise<{
fiatCurrencies: MeldFiatCurrency[] | null
error: string[] | null
}> => ({
fiatCurrencies: [
{
currencyCode: 'usd',
name: 'United States Currency',
symbolImageUrl: ''
}
],
error: null
})
}

keyringService: Partial<
InstanceType<typeof BraveWallet.KeyringServiceInterface>
> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const LOCAL_STORAGE_KEYS = {
GROUP_PORTFOLIO_NFTS_BY_COLLECTION: 'GROUP_PORTFOLIO_NFTS_BY_COLLECTION',
NFT_COLLECTION_NAMES_REGISTRY: 'NFT_COLLECTION_NAMES_REGISTRY2',
FILTERED_OUT_DAPP_NETWORK_KEYS: 'BRAVE_WALLET_FILTERED_OUT_DAPP_NETWORK_KEYS',
FILTERED_OUT_DAPP_CATEGORIES: 'BRAVE_WALLET_FILTERED_OUT_DAPP_CATEGORIES'
FILTERED_OUT_DAPP_CATEGORIES: 'BRAVE_WALLET_FILTERED_OUT_DAPP_CATEGORIES',
HAS_ACCEPTED_PARTNER_TERMS: 'BRAVE_WALLET_HAS_ACCEPTED_PARTNER_TERMS'
} as const

const LOCAL_STORAGE_KEYS_DEPRECATED = {
Expand Down
264 changes: 264 additions & 0 deletions components/brave_wallet_ui/common/constants/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// types
import {
BraveWallet,
MeldCountry,
MeldCryptoCurrency,
MeldFiatCurrency,
MeldPaymentMethod,
SerializableTransactionInfo,
SpotPriceRegistry
} from '../../constants/types'
Expand Down Expand Up @@ -1740,3 +1744,263 @@ export const mockTokenBalanceRegistry: TokenBalancesRegistry = {
}
}
}

export const mockMeldFiatCurrency: MeldFiatCurrency = {
currencyCode: 'USD',
name: 'United States Dollar',
symbolImageUrl: ''
}

export const mockMeldFiatCurrencies: MeldFiatCurrency[] = [
{
'currencyCode': 'AFN',
'name': 'Afghani',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/AFN/symbol.png'
},
{
'currencyCode': 'DZD',
'name': 'Algerian Dinar',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/DZD/symbol.png'
},
{
'currencyCode': 'ARS',
'name': 'Argentine Peso',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/ARS/symbol.png'
},
{
'currencyCode': 'AMD',
'name': 'Armenian Dram',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/AMD/symbol.png'
},
{
'currencyCode': 'AWG',
'name': 'Aruban Florin',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/AWG/symbol.png'
},
{
'currencyCode': 'AUD',
'name': 'Australian Dollar',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/AUD/symbol.png'
},
{
'currencyCode': 'AZN',
'name': 'Azerbaijan Manat',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/AZN/symbol.png'
},
{
'currencyCode': 'BSD',
'name': 'Bahamian Dollar',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/BSD/symbol.png'
},
{
'currencyCode': 'BHD',
'name': 'Bahraini Dinar',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/BHD/symbol.png'
},
{
'currencyCode': 'THB',
'name': 'Baht',
'symbolImageUrl': 'https://images-currency.meld.io/fiat/THB/symbol.png'
}
]

export const mockMeldCryptoCurrencies: MeldCryptoCurrency[] = [
{
'currencyCode': '00',
'name': '00 Token',
'chainCode': 'ETH',
'chainName': 'Ethereum',
'chainId': '0x1',
'contractAddress': undefined,
'symbolImageUrl': 'https://images-currency.meld.io/crypto/00/symbol.png'
},
{
'currencyCode': 'ZRX',
'name': '0x',
'chainCode': 'ETH',
'chainName': 'Ethereum',
'chainId': '0x1',
'contractAddress': '0xe41d2489571d322189246dafa5ebde1f4699f498',
'symbolImageUrl': 'https://images-currency.meld.io/crypto/ZRX/symbol.png'
},
{
'currencyCode': 'OXD_FTM',
'name': '0xDAO',
'chainCode': 'FTM',
'chainName': 'Fantom',
'chainId': '0xfa',
'contractAddress': undefined,
'symbolImageUrl':
'https://images-currency.meld.io/crypto/OXD_FTM/symbol.png'
},
{
'currencyCode': '1INCH',
'name': '1inch',
'chainCode': 'ETH',
'chainName': 'Ethereum',
'chainId': '0x1',
'contractAddress': '0x111111111117dc0aa78b770fa6a738034120c302',
'symbolImageUrl': 'https://images-currency.meld.io/crypto/1INCH/symbol.png'
},
{
'currencyCode': '1INCH_BSC',
'name': '1inch',
'chainCode': 'BSC',
'chainName': 'BNB Smart Chain',
'chainId': '0x38',
'contractAddress': '0x111111111117dc0aa78b770fa6a738034120c302',
'symbolImageUrl':
'https://images-currency.meld.io/crypto/1INCH_BSC/symbol.png'
}
]

export const mockMeldCryptoQuotes = [
{
'transactionType': 'CRYPTO_PURCHASE',
'exchangeRate': '3355.431',
'transactionFee': '4.99',
'sourceCurrencyCode': 'USD',
'sourceAmount': '100',
'sourceAmountWithoutFee': '93.23',
'fiatAmountWithoutFees': '93.23',
'totalFee': '6.77',
'networkFee': '0.78',
'paymentMethod': 'CREDIT_DEBIT_CARD',
'destinationCurrencyCode': 'ETH',
'destinationAmount': '0.02980243',
'destinationAmountWithoutFees': undefined,
'customerScore': '20.0',
'serviceProvider': 'TRANSAK',
'countryCode': 'US'
}
]

export const mockServiceProviders = [
{
'name': 'Transak',
'serviceProvider': 'TRANSAK',
'status': 'LIVE',
'webSiteUrl': 'https://transak.com',
'categories': ['CRYPTO_OFFRAMP', 'CRYPTO_ONRAMP'],
'categoryStatuses': {
'CRYPTO_OFFRAMP': 'LIVE',
'CRYPTO_ONRAMP': 'LIVE'
},
'logoImages': {
'darkUrl': 'https://images-serviceprovider.meld.io/TRANSAK/logo_dark.png',
'darkShortUrl':
'https://images-serviceprovider.meld.io/TRANSAK/short_logo_dark.png',
'lightUrl':
'https://images-serviceprovider.meld.io/TRANSAK/logo_light.png',
'lightShortUrl':
'https://images-serviceprovider.meld.io/TRANSAK/short_logo_light.png'
}
}
]

export const mockMeldCountries = [
{
'countryCode': 'AF',
'name': 'Afghanistan',
'flagImageUrl': 'https://images-country.meld.io/AF/flag.svg',
'regions': null
},
{
'countryCode': 'AL',
'name': 'Albania',
'flagImageUrl': 'https://images-country.meld.io/AL/flag.svg',
'regions': null
},
{
'countryCode': 'DZ',
'name': 'Algeria',
'flagImageUrl': 'https://images-country.meld.io/DZ/flag.svg',
'regions': null
},
{
'countryCode': 'AS',
'name': 'American Samoa',
'flagImageUrl': 'https://images-country.meld.io/AS/flag.svg',
'regions': null
},
{
'countryCode': 'AD',
'name': 'Andorra',
'flagImageUrl': 'https://images-country.meld.io/AD/flag.svg',
'regions': null
}
] as unknown as MeldCountry[]

export const mockMeldPaymentMethods = [
{
'paymentMethod': 'APPLE_PAY',
'name': 'Apple Pay',
'paymentType': 'MOBILE_WALLET',
'logoImages': {
'darkUrl': 'https://images-paymentMethod.meld.io/APPLE_PAY/logo_dark.png',
'darkShortUrl': null,
'lightUrl':
'https://images-paymentMethod.meld.io/APPLE_PAY/logo_light.png',
'lightShortUrl': null
}
},
{
'paymentMethod': 'CREDIT_DEBIT_CARD',
'name': 'Credit & Debit Card',
'paymentType': 'CARD',
'logoImages': {
'darkUrl':
'https://images-paymentMethod.meld.io/CREDIT_DEBIT_CARD/logo_dark.png',
'darkShortUrl': null,
'lightUrl':
'https://images-paymentMethod.meld.io/CREDIT_DEBIT_CARD/logo_light.png',
'lightShortUrl': null
}
},
{
'paymentMethod': 'FAST',
'name': 'FAST',
'paymentType': 'BANK_TRANSFER',
'logoImages': {
'darkUrl': 'https://images-paymentMethod.meld.io/FAST/logo_dark.png',
'darkShortUrl': null,
'lightUrl': 'https://images-paymentMethod.meld.io/FAST/logo_light.png',
'lightShortUrl': null
}
},
{
'paymentMethod': 'NG_BANK_TRANSFER',
'name': 'Local Manual Bank Transfer',
'paymentType': 'BANK_TRANSFER',
'logoImages': {
'darkUrl':
'https://images-paymentMethod.meld.io/NG_BANK_TRANSFER/logo_dark.png',
'darkShortUrl': null,
'lightUrl':
'https://images-paymentMethod.meld.io/NG_BANK_TRANSFER/logo_light.png',
'lightShortUrl': null
}
},
{
'paymentMethod': 'SEPA',
'name': 'SEPA',
'paymentType': 'BANK_TRANSFER',
'logoImages': {
'darkUrl': 'https://images-paymentMethod.meld.io/SEPA/logo_dark.png',
'darkShortUrl': null,
'lightUrl': 'https://images-paymentMethod.meld.io/SEPA/logo_light.png',
'lightShortUrl': null
}
},
{
'paymentMethod': 'SPEI',
'name': 'SPEI',
'paymentType': 'BANK_TRANSFER',
'logoImages': {
'darkUrl': 'https://images-paymentMethod.meld.io/SPEI/logo_dark.png',
'darkShortUrl': null,
'lightUrl': 'https://images-paymentMethod.meld.io/SPEI/logo_light.png',
'lightShortUrl': null
}
}
] as unknown as MeldPaymentMethod[]
Loading
Loading