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

chore: enable multiselect in asset-picker network modal #28975

Merged
merged 70 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
788ddba
chore: enable overriding asset-picker button layout
micaelae Nov 1, 2024
3c20e29
fix: hide dest chain balances in AssetList
micaelae Nov 6, 2024
6bdac99
chore: add loading indicator to AssetList
micaelae Nov 7, 2024
2db748e
chore: use default network name in asset-picker network modal
micaelae Nov 8, 2024
257aacf
chore: don't default to active network
micaelae Nov 8, 2024
577531f
chore: disable network list item based on callback
micaelae Nov 8, 2024
3c2f7fd
chore: update network picker modal headers
micaelae Nov 8, 2024
7f5246f
chore: update back button behaviour for asset/network picker
micaelae Nov 8, 2024
61ad0ed
fix: dedupe AssetList items when tokens have same symbol
micaelae Nov 9, 2024
7bb449c
fix: prevent balance wrapping in asset picker
micaelae Nov 9, 2024
a3c1aca
chore: update asset picker stories
micaelae Nov 12, 2024
1777649
fix: unit tests and network picker modal snapshots
micaelae Nov 12, 2024
db33a69
fix: update prepare-bridge-page snapshots
micaelae Nov 12, 2024
1a40694
fix: rm comment
micaelae Nov 12, 2024
a57d809
fix: localize loading text
micaelae Nov 12, 2024
82c2713
fix: replace hardcoded values with variables
micaelae Nov 12, 2024
2592d6e
chore: useMultichainBalances hook
micaelae Dec 4, 2024
e7255a5
chore: add NetworkListItem endAccesory prop
micaelae Dec 3, 2024
02d7272
chore: display multiple chain icons in PickerNetwork
micaelae Dec 4, 2024
f10c84a
chore: style AssetPicker search field
micaelae Dec 4, 2024
5b2d685
chore: style AssetPicker Network picker
micaelae Dec 4, 2024
cc6a462
chore: add isMultiselectEnabled to network modal
micaelae Dec 5, 2024
36bbdba
chore: sort networks by balance
micaelae Dec 5, 2024
6a713ca
chore: use multichain assets in asset-picker
micaelae Dec 5, 2024
1d3fe3d
chore: display multiple networks in PickerNetwork
micaelae Dec 5, 2024
ac0ef71
chore: NetworkListItem variant prop and fix console warning
micaelae Dec 5, 2024
a96e687
fix: prevent autoscroll to top of asset picker
micaelae Dec 5, 2024
70c2e7a
chore: enable multichain selection in bridge page
micaelae Dec 5, 2024
b534ec9
fix: snapshot tests
micaelae Dec 5, 2024
24ebcb0
chore: clean up + add comments
micaelae Dec 5, 2024
b5c149f
fix: unit test
micaelae Dec 6, 2024
9ed13fb
fix: lint errors
micaelae Dec 6, 2024
51ca5e2
fix: unit tests
micaelae Dec 6, 2024
645c963
fix: rm left margin in asset list
micaelae Dec 6, 2024
ea580b2
fix: unit tests
micaelae Dec 6, 2024
453e80e
fix: network modal scrolling
micaelae Dec 6, 2024
2397482
fix: disable search autofocus if multiselect is enabled
micaelae Dec 6, 2024
120a9fa
chore: display multiple network avatars in PickerNetwork + AvatarGroup
micaelae Dec 6, 2024
7e7a2f8
fix: Send flow tokens have no chainId
micaelae Dec 6, 2024
af9d843
fix: update checkbox state when network changes outside of asset picker
micaelae Dec 7, 2024
c284243
fix: make TokenListItem subtitles text variant consistent
micaelae Dec 8, 2024
11b5ac9
fix: network + asset onBack navigation
micaelae Dec 8, 2024
fd70610
chore: show network name as bridge token title (no title for dest tok…
micaelae Dec 9, 2024
537a3ca
chore: show shortened network names in network picker modal
micaelae Dec 9, 2024
5fe1ac6
chore: set token list item height
micaelae Dec 9, 2024
aae7aac
fix: snapshots
micaelae Dec 9, 2024
aba0016
chore: allow unimported networks to be shown in network modal
micaelae Dec 9, 2024
c8992d9
fix: useMultiChainBalances should not fail when erc20Tokens are not c…
micaelae Dec 9, 2024
06eb4ef
fix: bridge asset type
micaelae Dec 9, 2024
579e6e5
fix: asset-picker stories
micaelae Dec 9, 2024
d49be39
fix: asset-picker-modal and AssetList tests
micaelae Dec 9, 2024
1a2ce6a
fix: handle empty/undefined props
micaelae Dec 9, 2024
00fff17
chore: add unit tests for useMultichainBalances
micaelae Dec 10, 2024
a5d6370
chore: add story for AvatarGroup
micaelae Dec 10, 2024
257f3b4
refactor: PickerNetwork + AvatarGroup + stories
micaelae Dec 10, 2024
27e8ae4
chore: rm unused message
micaelae Dec 10, 2024
2b08a75
fix: unit tests
micaelae Dec 10, 2024
84faab7
fix: e2e tests
micaelae Dec 10, 2024
e7c4d49
fix: hide token balances when chain is not in wallet
micaelae Dec 10, 2024
59a6247
fix: bridge token list
micaelae Dec 10, 2024
d007c9b
fix: unit tests
micaelae Dec 10, 2024
3576bbb
chore: add snapshot tests for TokenListItem
micaelae Dec 10, 2024
e2604f9
chore: refactor TokenListItem for less truncation
micaelae Dec 10, 2024
8fa13f8
fix: update token-list-item snapshots
micaelae Dec 10, 2024
a9d2b11
fix: e2e tests
micaelae Dec 10, 2024
ad5f129
fix: unit tests
micaelae Dec 10, 2024
300954f
chore: add unit tests for PickerNetwork
micaelae Dec 11, 2024
d83cd7c
fix: double border in AvatarGroup for networks
micaelae Dec 11, 2024
696ece7
fix: snapshots
micaelae Dec 11, 2024
139c9c3
fix: missing translation
micaelae Dec 11, 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
16 changes: 16 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion shared/constants/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CHAIN_IDS } from './network';
import { CHAIN_IDS, NETWORK_TO_NAME_MAP } from './network';

// TODO read from feature flags
export const ALLOWED_BRIDGE_CHAIN_IDS = [
Expand Down Expand Up @@ -31,3 +31,18 @@ export const BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE = 0.8; // if a quote

export const BRIDGE_PREFERRED_GAS_ESTIMATE = 'medium';
export const BRIDGE_DEFAULT_SLIPPAGE = 0.5;

export const NETWORK_TO_SHORT_NETWORK_NAME_MAP: Record<
AllowedBridgeChainIds,
string
> = {
[CHAIN_IDS.MAINNET]: 'Ethereum',
[CHAIN_IDS.LINEA_MAINNET]: 'Linea',
[CHAIN_IDS.POLYGON]: NETWORK_TO_NAME_MAP[CHAIN_IDS.POLYGON],
[CHAIN_IDS.AVALANCHE]: 'Avalanche',
[CHAIN_IDS.BSC]: NETWORK_TO_NAME_MAP[CHAIN_IDS.BSC],
[CHAIN_IDS.ARBITRUM]: NETWORK_TO_NAME_MAP[CHAIN_IDS.ARBITRUM],
[CHAIN_IDS.OPTIMISM]: NETWORK_TO_NAME_MAP[CHAIN_IDS.OPTIMISM],
[CHAIN_IDS.ZKSYNC_ERA]: 'ZkSync Era',
[CHAIN_IDS.BASE]: 'Base',
};
5 changes: 5 additions & 0 deletions test/data/mock-send-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
},
"metamask": {
"accountsByChainId": {},
"tokenBalances": {
"0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": {
"0x5": {}
}
},
"ipfsGateway": "",
"dismissSeedBackUpReminder": false,
"usePhishDetect": true,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/page-objects/pages/home/asset-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AssetListPage {
*/
async hideToken(tokenName: string): Promise<void> {
console.log(`Hide token ${tokenName} on homepage`);
await this.driver.clickElement({ text: tokenName, tag: 'span' });
await this.driver.clickElement({ text: tokenName, tag: 'p' });
await this.driver.clickElement(this.assetOptionsButton);
await this.driver.clickElement(this.hideTokenButton);
await this.driver.waitForSelector(this.hideTokenConfirmationModalTitle);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/dapp-interactions/block-explorer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Block Explorer', function () {

await driver.clickElement({
text: 'TST',
tag: 'span',
tag: 'p',
});

await driver.clickElement('[data-testid="asset-options__button"]');
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/multichain/asset-picker-send.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('AssetPickerSendFlow @no-mmi', function () {
await searchInputField.sendKeys('CHZ');

// check that CHZ is disabled
const [, tkn] = await driver.findElements(
const [tkn] = await driver.findElements(
'[data-testid="multichain-token-list-button"]',
);

Expand Down
1 change: 1 addition & 0 deletions test/e2e/tests/network/custom-rpc-history.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ describe('Custom RPC history', function () {
const customRpcs = await driver.findElements({
text: 'Localhost 8545',
tag: 'p',
css: '.multichain-network-list-item__tooltip',
});

// click Mainnet to dismiss network dropdown
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/network/update-network.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const selectors = {
deleteButton: { text: 'Delete', tag: 'button' },
cancelButton: { text: 'Cancel', tag: 'button' },
saveButton: { text: 'Save', tag: 'button' },
updatedNetworkDropDown: { tag: 'span', text: 'Update Network' },
updatedNetworkDropDown: { tag: 'p', text: 'Update Network' },
errorMessageInvalidUrl: {
text: 'URLs require the appropriate HTTP/HTTPS prefix.',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('MetaMask Responsive UI', function () {

// Import Secret Recovery Phrase
await driver.waitForSelector({
tag: 'span',
tag: 'p',
text: 'Localhost 8545',
});
await driver.clickElement({
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/tokens/add-multiple-tokens.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Multiple ERC20 Watch Asset', function () {

// Check all three tokens have been added to the token list.
const addedTokens = await driver.findElements({
tag: 'span',
tag: 'p',
text: 'TST',
});
assert.equal(addedTokens.length, 3);
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tests/transaction/change-assets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('Change assets', function () {

// Click the Send button
await driver.clickElement({
css: '[data-testid="multichain-token-list-button"] span',
css: '[data-testid="multichain-token-list-button"] p',
text: 'TST',
});

Expand Down Expand Up @@ -471,7 +471,7 @@ describe('Change assets', function () {

// Click the Send button
await driver.clickElement({
css: '[data-testid="multichain-token-list-button"] span',
css: '[data-testid="multichain-token-list-button"] p',
text: 'TST',
});

Expand Down
107 changes: 107 additions & 0 deletions test/jest/mock-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,113 @@ export const createBridgeMockStore = (
},
currencyRates: {
ETH: { conversionRate: 2524.25 },
usd: { conversionRate: 1 },
},
marketData: {
'0x1': {
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984': {
currency: 'usd',
price: 2.3,
},
},
},
allTokens: {
[CHAIN_IDS.MAINNET]: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': [
{
address: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
balance: 'a',
decimals: 6,
},
{
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
balance: 'e',
},
],
'0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b': [
{
address: '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2',
balance: 'e',
},
],
},
[CHAIN_IDS.LINEA_MAINNET]: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': [
{
address: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
balance: 'e',
},
],
'0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b': [
{
address: '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2',
balance: 'e',
},
],
},
},
accountsByChainId: {
[CHAIN_IDS.MAINNET]: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
balance: '0xa',
},
'0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b': {
address: '0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b',
balance: '0xe',
},
},
[CHAIN_IDS.LINEA_MAINNET]: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
balance: '0xe',
},
'0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b': {
address: '0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b',
balance: '0xe',
},
},
},
tokensChainsCache: {
[CHAIN_IDS.MAINNET]: {
timestamp: 111111,
data: [
{
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
symbol: 'LINK',
decimals: 18,
},
{
address: '0xc00e94cb662c3520282e6f5717214004a7f26888',
symbol: 'COMP',
decimals: 18,
},
],
},
[CHAIN_IDS.LINEA_MAINNET]: {
timestamp: 111111,
data: {
'0x514910771af9ca656af840dff83e8264ecf986ca': {
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
symbol: 'LINK',
decimals: 18,
},
'0xc00e94cb662c3520282e6f5717214004a7f26888': {
address: '0xc00e94cb662c3520282e6f5717214004a7f26888',
symbol: 'COMP',
decimals: 18,
},
},
},
},
tokenBalances: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
'0x5': {},
'0x1': {
'0x514910771af9ca656af840dff83e8264ecf986ca': '0x1',
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984': '0x738',
},
},
},
...metamaskStateOverrides,
bridgeState: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
exports[`Token Cell should match snapshot 1`] = `
<div>
<div
class="mm-box multichain-token-list-item mm-box--display-flex mm-box--gap-4 mm-box--flex-direction-column"
class="mm-box multichain-token-list-item mm-box--display-flex mm-box--gap-4 mm-box--flex-direction-row mm-box--width-full mm-box--height-full"
data-testid="multichain-token-list-item"
>
<a
class="mm-box multichain-token-list-item__container-cell multichain-token-list-item__container-cell--clickable mm-box--padding-top-2 mm-box--padding-right-4 mm-box--padding-bottom-2 mm-box--padding-left-4 mm-box--display-flex mm-box--flex-direction-row"
class="mm-box multichain-token-list-item__container-cell multichain-token-list-item__container-cell--clickable mm-box--padding-top-2 mm-box--padding-right-4 mm-box--padding-bottom-2 mm-box--padding-left-4 mm-box--display-flex mm-box--flex-direction-row mm-box--width-full"
data-testid="multichain-token-list-button"
href="#"
style="height: 62px;"
>
<div
class="mm-box mm-badge-wrapper multichain-token-list-item__badge mm-box--margin-right-4 mm-box--display-inline-block"
Expand Down Expand Up @@ -38,51 +39,44 @@ exports[`Token Cell should match snapshot 1`] = `
</div>
</div>
<div
class="mm-box multichain-token-list-item__container-cell--text-container mm-box--display-flex mm-box--flex-direction-column mm-box--width-full"
class="mm-box multichain-token-list-item__container-cell--text-container mm-box--display-flex mm-box--flex-direction-column mm-box--justify-content-center mm-box--width-full"
style="flex-grow: 1; overflow: hidden;"
>
<div
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--flex-direction-row mm-box--justify-content-space-between"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-space-between"
>
<div
class="mm-box mm-box--display-inline-block mm-box--width-1/3"
<p
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--ellipsis mm-box--color-text-default"
>
<span
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--ellipsis mm-box--color-text-default"
>
TEST
</span>
<div
class="mm-box mm-box--display-flex"
>
<p
class="mm-box mm-text mm-text--body-sm-medium mm-text--ellipsis mm-box--color-text-default"
data-testid="token-increase-decrease-percentage-0xAnotherToken"
/>
</div>
</div>
TEST
</p>
<p
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--text-align-end mm-box--color-text-default"
data-testid="multichain-token-list-item-secondary-value"
>
$5.00
</p>
</div>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-space-between"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-column mm-box--align-items-flex-end mm-box--width-2/3"
class="mm-box mm-box--display-flex"
>
<p
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--text-align-end mm-box--width-2/3 mm-box--color-text-default"
data-testid="multichain-token-list-item-secondary-value"
>
$5.00
</p>
<p
class="mm-box mm-text mm-text--body-sm-medium mm-text--text-align-end mm-box--color-text-alternative"
data-testid="multichain-token-list-item-value"
>
5

TEST
</p>
class="mm-box mm-text mm-text--body-sm-medium mm-text--ellipsis mm-box--color-text-default"
data-testid="token-increase-decrease-percentage-0xAnotherToken"
/>
</div>
<p
class="mm-box mm-text mm-text--body-sm-medium mm-text--text-align-end mm-box--color-text-alternative"
data-testid="multichain-token-list-item-value"
>
5

TEST
</p>
</div>
<div
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--flex-direction-row mm-box--justify-content-space-between"
/>
</div>
</a>
</div>
Expand Down
Loading
Loading