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(ramps): introduces dynamic support for rampable networks #24041

Merged
merged 93 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
8bda667
feat(ramps): introduce dynamic support for rampable networks
georgeweiler Apr 16, 2024
7c4ba77
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Apr 16, 2024
c4f1fb9
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 16, 2024
7fe1f84
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 16, 2024
5349c10
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Apr 17, 2024
8fecf66
refactor(ramps): updates file directory to organize ramps hooks and u…
georgeweiler Apr 17, 2024
364713f
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Apr 17, 2024
91521fc
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 17, 2024
988e985
chore(ramps): cleans up some code based on review comments
georgeweiler Apr 18, 2024
ba291c7
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Apr 18, 2024
9de918e
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 18, 2024
4e18dbf
chore(ramps): updates mock-send-state to use up to date list of buyab…
georgeweiler Apr 18, 2024
3afb831
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Apr 18, 2024
7048723
chore: fixes ramp api test
georgeweiler Apr 18, 2024
62b1e54
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 19, 2024
bf646c7
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Apr 19, 2024
69fb2f8
chore: fixes network interface issues
georgeweiler Apr 19, 2024
1d29388
chore: fix lint issue
georgeweiler Apr 19, 2024
2d84d11
chore: updates privacy snapshot for e2e tests
georgeweiler Apr 19, 2024
48fe591
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 19, 2024
13ac2b7
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 22, 2024
707f387
chore: use set instead of append for url params
georgeweiler Apr 22, 2024
e8bbf4f
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Apr 22, 2024
04b5c8f
feat(ramps): adds more defensible code to protect against corrupted r…
georgeweiler Apr 22, 2024
c1d8b09
chore: add https://on-ramp-content.uat-api.cx.metamask.io/ to privacy…
georgeweiler Apr 22, 2024
f938618
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Apr 22, 2024
0091f86
chore: fixes ramps api test
georgeweiler Apr 22, 2024
debd520
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Apr 22, 2024
bb7a204
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler May 1, 2024
48c028a
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler May 7, 2024
c193631
chore: adds ramp api to privact snapshot
georgeweiler May 10, 2024
81858cf
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler May 10, 2024
2a8cc16
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 10, 2024
75f0806
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 10, 2024
142d6ad
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 14, 2024
1497a38
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 14, 2024
0d26083
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 14, 2024
a9d8eec
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 15, 2024
29fe0bf
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 15, 2024
b2f55c3
Merge branch 'develop' into ramps-buyable-networks
nikoferro May 16, 2024
a5b3403
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 16, 2024
5825434
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 16, 2024
c977225
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 17, 2024
0303f25
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler May 17, 2024
ca784bf
chore: removes require-actual from routes component test
georgeweiler May 17, 2024
8862e20
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler May 17, 2024
c08abf9
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 20, 2024
53606d7
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 20, 2024
4cb8b13
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 21, 2024
3331cbc
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 21, 2024
a9cfbf2
Merge branch 'develop' into ramps-buyable-networks
georgeweiler May 21, 2024
4450851
Merge branch 'develop' into ramps-buyable-networks
wachunei May 22, 2024
d75e639
Merge branch 'develop' into ramps-buyable-networks
wachunei May 24, 2024
19d0c7a
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Jun 18, 2024
335e99e
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Jun 18, 2024
52088d3
chore(ramps): removes previously deleted files
georgeweiler Jun 18, 2024
e4312d6
chore(ramps): fixes linting errors after rebasing with develop branch
georgeweiler Jun 18, 2024
8782836
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Jun 19, 2024
fc643ab
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 20, 2024
71ebebc
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 20, 2024
c9b1dab
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 20, 2024
379a2d8
chore(ramps): adds build gate comment to import that failed linting
georgeweiler Jun 20, 2024
29fa2e6
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Jun 20, 2024
6ede0cd
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 20, 2024
8565acd
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 20, 2024
fb2de48
chore(ramps): adds more build gate comments to import that failed lin…
georgeweiler Jun 20, 2024
e18e3f5
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Jun 20, 2024
9abd7f2
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 20, 2024
6cb9380
chore(ramps): adds more build gate comments to import that failed lin…
georgeweiler Jun 20, 2024
d6e03ff
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Jun 20, 2024
ef42cf6
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 20, 2024
242d3b9
chore(ramps): adds more build gate comments to import that failed lin…
georgeweiler Jun 20, 2024
9fef50a
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Jun 20, 2024
530eab0
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
df96b09
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
cf96285
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
800793f
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
7c09dc0
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
6403c53
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
7e8f644
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
dd07da1
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
49737ac
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
2e2dc80
chore(ramps): fixes linting errors after rebasing with develop branch
georgeweiler Jun 21, 2024
030af03
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
87515c9
Merge branch 'develop' into ramps-buyable-networks
georgeweiler Jun 21, 2024
e66e77c
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Jun 24, 2024
b637252
fix(ramps): use jest.mocked instead of suppressing TS error
georgeweiler Jun 24, 2024
ee44685
Merge branch 'ramps-buyable-networks' of https://github.com/MetaMask/…
georgeweiler Jun 24, 2024
a53b8b2
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Jun 26, 2024
13bdc3b
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Jun 27, 2024
ba2eefa
feat(ramps): do not make requests to ramp api if basic functionality …
georgeweiler Jun 27, 2024
1c56c3f
Merge branch 'develop' of https://github.com/MetaMask/metamask-extens…
georgeweiler Jun 27, 2024
7ee6250
fix: resolves mmi e2e test error
georgeweiler Jun 27, 2024
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
2 changes: 2 additions & 0 deletions builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ env:
# Enables the notifications feature within the build:
- NOTIFICATIONS: ''

- METAMASK_RAMP_API_BASE_URL: https://on-ramp-content.metaswap.codefi.network
wachunei marked this conversation as resolved.
Show resolved Hide resolved

###
# Meta variables
###
Expand Down
1 change: 1 addition & 0 deletions privacy-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"mainnet.infura.io",
"metamask.github.io",
"min-api.cryptocompare.com",
"on-ramp-content.metaswap.codefi.network",
"phishing-detection.metafi.codefi.network",
"portfolio.metamask.io",
"price-api.metafi.codefi.network",
Expand Down
111 changes: 0 additions & 111 deletions shared/constants/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ export type RPCDefinition = {
rpcPrefs: RPCPreferences;
};

/**
* For each chain that we support fiat onramps for, we provide a set of
* configuration options that help for initializing the connectiong to the
* onramp providers.
*/
type BuyableChainSettings = {
/**
* The native currency for the given chain
*/
nativeCurrency: CurrencySymbol | TestNetworkCurrencySymbol;
/**
* The network name or identifier
*/
network: string;
};

/**
* Throughout the extension we set the current provider by referencing its
* "type", which can be any of the values in the below object. These values
Expand Down Expand Up @@ -859,101 +843,6 @@ export const UNSUPPORTED_RPC_METHODS = new Set([

export const IPFS_DEFAULT_GATEWAY_URL = 'dweb.link';

// The first item in transakCurrencies must be the
// default crypto currency for the network
const BUYABLE_CHAIN_ETHEREUM_NETWORK_NAME = 'ethereum';

export const BUYABLE_CHAINS_MAP: {
[K in Exclude<
ChainId,
| typeof CHAIN_IDS.LOCALHOST
| typeof CHAIN_IDS.OPTIMISM_TESTNET
| typeof CHAIN_IDS.OPTIMISM_GOERLI
| typeof CHAIN_IDS.BASE_TESTNET
| typeof CHAIN_IDS.OPBNB_TESTNET
| typeof CHAIN_IDS.OPBNB
| typeof CHAIN_IDS.BSC_TESTNET
| typeof CHAIN_IDS.POLYGON_TESTNET
| typeof CHAIN_IDS.AVALANCHE_TESTNET
| typeof CHAIN_IDS.FANTOM_TESTNET
| typeof CHAIN_IDS.MOONBEAM_TESTNET
| typeof CHAIN_IDS.LINEA_GOERLI
| typeof CHAIN_IDS.LINEA_SEPOLIA
| typeof CHAIN_IDS.GOERLI
| typeof CHAIN_IDS.SEPOLIA
| typeof CHAIN_IDS.GNOSIS
| typeof CHAIN_IDS.AURORA
| typeof CHAIN_IDS.ARBITRUM_GOERLI
| typeof CHAIN_IDS.BLAST
| typeof CHAIN_IDS.FILECOIN
>]: BuyableChainSettings;
} = {
[CHAIN_IDS.MAINNET]: {
nativeCurrency: CURRENCY_SYMBOLS.ETH,
network: BUYABLE_CHAIN_ETHEREUM_NETWORK_NAME,
},
[CHAIN_IDS.BSC]: {
nativeCurrency: CURRENCY_SYMBOLS.BNB,
network: 'bsc',
},
[CHAIN_IDS.POLYGON]: {
nativeCurrency: CURRENCY_SYMBOLS.MATIC,
network: 'polygon',
},
[CHAIN_IDS.AVALANCHE]: {
nativeCurrency: CURRENCY_SYMBOLS.AVALANCHE,
network: 'avaxcchain',
},
[CHAIN_IDS.FANTOM]: {
nativeCurrency: CURRENCY_SYMBOLS.FANTOM,
network: 'fantom',
},
[CHAIN_IDS.CELO]: {
nativeCurrency: CURRENCY_SYMBOLS.CELO,
network: 'celo',
},
[CHAIN_IDS.OPTIMISM]: {
nativeCurrency: CURRENCY_SYMBOLS.ETH,
network: 'optimism',
},
[CHAIN_IDS.ARBITRUM]: {
nativeCurrency: CURRENCY_SYMBOLS.ARBITRUM,
network: 'arbitrum',
},
[CHAIN_IDS.CRONOS]: {
nativeCurrency: CURRENCY_SYMBOLS.CRONOS,
network: 'cronos',
},
[CHAIN_IDS.MOONBEAM]: {
nativeCurrency: CURRENCY_SYMBOLS.GLIMMER,
network: 'moonbeam',
},
[CHAIN_IDS.MOONRIVER]: {
nativeCurrency: CURRENCY_SYMBOLS.MOONRIVER,
network: 'moonriver',
},
[CHAIN_IDS.HARMONY]: {
nativeCurrency: CURRENCY_SYMBOLS.ONE,
network: 'harmony',
},
[CHAIN_IDS.PALM]: {
nativeCurrency: CURRENCY_SYMBOLS.PALM,
network: 'palm',
},
[CHAIN_IDS.LINEA_MAINNET]: {
nativeCurrency: CURRENCY_SYMBOLS.ETH,
network: 'linea',
},
[CHAIN_IDS.ZKSYNC_ERA]: {
nativeCurrency: CURRENCY_SYMBOLS.ETH,
network: 'zksync',
},
[CHAIN_IDS.BASE]: {
nativeCurrency: CURRENCY_SYMBOLS.ETH,
network: 'base',
},
};

export const FEATURED_RPCS: RPCDefinition[] = [
{
chainId: CHAIN_IDS.ARBITRUM,
Expand Down
82 changes: 82 additions & 0 deletions test/data/mock-send-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,88 @@
}
]
},
"ramps": {
"buyableChains": [
{
"active": true,
"chainId": 1,
"chainName": "Ethereum Mainnet",
"nativeTokenSupported": true
wachunei marked this conversation as resolved.
Show resolved Hide resolved
},
{
"active": true,
"chainId": 10,
"chainName": "Optimism Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 25,
"chainName": "Cronos Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 56,
"chainName": "BNB Chain Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 137,
"chainName": "Polygon Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 250,
"chainName": "Fantom Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 1285,
"chainName": "Moonriver Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 42161,
"chainName": "Arbitrum Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 42220,
"chainName": "Celo Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 43114,
"chainName": "Avalanche C-Chain Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 1313161554,
"chainName": "Aurora Mainnet",
"nativeTokenSupported": false
},
{
"active": true,
"chainId": 1666600000,
"chainName": "Harmony Mainnet (Shard 0)",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 11297108109,
"chainName": "Palm",
"nativeTokenSupported": false
}
]
},
"send": {
"amountMode": "INPUT",
"currentTransactionUUID": "1-tx",
Expand Down
82 changes: 82 additions & 0 deletions test/data/mock-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,88 @@
}
}
},
"ramps": {
"buyableChains": [
{
"active": true,
"chainId": 1,
"chainName": "Ethereum Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 10,
"chainName": "Optimism Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 25,
"chainName": "Cronos Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 56,
"chainName": "BNB Chain Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 137,
"chainName": "Polygon Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 250,
"chainName": "Fantom Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 1285,
"chainName": "Moonriver Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 42161,
"chainName": "Arbitrum Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 42220,
"chainName": "Celo Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 43114,
"chainName": "Avalanche C-Chain Mainnet",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 1313161554,
"chainName": "Aurora Mainnet",
"nativeTokenSupported": false
},
{
"active": true,
"chainId": 1666600000,
"chainName": "Harmony Mainnet (Shard 0)",
"nativeTokenSupported": true
},
{
"active": true,
"chainId": 11297108109,
"chainName": "Palm",
"nativeTokenSupported": false
}
]
},
"send": {
"amountMode": "INPUT",
"currentTransactionUUID": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"showAccountBanner": true,
"trezorModel": null,
"hadAdvancedGasFeesSetPriorToMigration92_3": false,
"hasDismissedOpenSeaToBlockaidBanner": false,
"nftsDropdownState": {},
"termsOfUseLastAgreed": "number",
"qrHardware": {},
Expand Down Expand Up @@ -103,6 +102,7 @@
"dismissSeedBackUpReminder": true,
"disabledRpcMethodPreferences": { "eth_sign": false },
"useMultiAccountBalanceChecker": true,
"hasDismissedOpenSeaToBlockaidBanner": false,
"useSafeChainsListValidation": true,
"useTokenDetection": false,
"useNftDetection": false,
Expand Down Expand Up @@ -229,6 +229,7 @@
"storageMetadata": {},
"versionFileETag": "string"
},
"ramps": "object",
"send": "object",
"swaps": "object",
"unconnectedAccount": { "state": "CLOSED" }
Expand Down
1 change: 1 addition & 0 deletions ui/components/app/add-network/add-network.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import mockState from '../../../../test/data/mock-state.json';
import AddNetwork from './add-network';

jest.mock('../../../selectors', () => ({
...jest.requireActual('../../../selectors'),
wachunei marked this conversation as resolved.
Show resolved Hide resolved
getNetworkConfigurations: () => ({
networkConfigurationId: {
chainId: '0x539',
Expand Down
6 changes: 2 additions & 4 deletions ui/components/app/asset-list/asset-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {
getDetectedTokensInCurrentNetwork,
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork,
getShouldHideZeroBalanceTokens,
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
getIsBuyableChain,
///: END:ONLY_INCLUDE_IF
getCurrentNetwork,
getSelectedAccount,
getPreferences,
Expand Down Expand Up @@ -48,6 +45,7 @@ import {
RAMPS_CARD_VARIANT_TYPES,
RampsCard,
} from '../../multichain/ramps-card/ramps-card';
import { getIsNativeTokenBuyable } from '../../../ducks/ramps';
///: END:ONLY_INCLUDE_IF

const AssetList = ({ onClickAsset }) => {
Expand Down Expand Up @@ -107,7 +105,7 @@ const AssetList = ({ onClickAsset }) => {
});
const balanceIsZero = Number(totalFiatBalance) === 0;
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
const isBuyableChain = useSelector(getIsBuyableChain);
const isBuyableChain = useSelector(getIsNativeTokenBuyable);
const shouldShowBuy = isBuyableChain && balanceIsZero;
///: END:ONLY_INCLUDE_IF

Expand Down
Loading
Loading