Skip to content

Commit

Permalink
Merge branch 'main' into feat/mmassets-476_network-icon-hover
Browse files Browse the repository at this point in the history
  • Loading branch information
gambinish authored Dec 19, 2024
2 parents ad0c716 + cd39d7b commit d567eab
Show file tree
Hide file tree
Showing 120 changed files with 1,972 additions and 964 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/wait-for-circleci-workflow-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ jobs:
OWNER: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
BRANCH: ${{ github.head_ref || github.ref_name }}
# For a `push` event, the HEAD commit hash is `github.sha`.
# For a `pull_request` event, `github.sha` is instead the base branch commit hash. The
# HEAD commit hash is `pull_request.head.sha`.
HEAD_COMMIT_HASH: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
pipeline_id=$(curl --silent "https://circleci.com/api/v2/project/gh/$OWNER/$REPOSITORY/pipeline?branch=$BRANCH" | jq -r ".items[0].id")
pipeline_id=$(curl --silent "https://circleci.com/api/v2/project/gh/$OWNER/$REPOSITORY/pipeline?branch=$BRANCH" | jq -r ".items | map(select(.vcs.revision == \"${HEAD_COMMIT_HASH}\" )) | first | .id")
echo "Waiting for pipeline '${pipeline_id}' for commit hash '${HEAD_COMMIT_HASH}'"
workflow_status=$(curl --silent "https://circleci.com/api/v2/pipeline/$pipeline_id/workflow" | jq -r ".items[0].status")
if [ "$workflow_status" == "running" ]; then
Expand Down
4 changes: 2 additions & 2 deletions app/_locales/en/messages.json

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

4 changes: 1 addition & 3 deletions app/scripts/controllers/bridge-status/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {
StatusRequestWithSrcTxHash,
StatusRequestDto,
} from '../../../../shared/types/bridge-status';
// TODO fix this
// eslint-disable-next-line import/no-restricted-paths
import { Quote } from '../../../../ui/pages/bridge/types';
import type { Quote } from '../../../../shared/types/bridge';
import { validateResponse, validators } from './validators';

const CLIENT_ID_HEADER = { 'X-Client-Id': BRIDGE_CLIENT_ID };
Expand Down
13 changes: 6 additions & 7 deletions app/scripts/controllers/bridge/bridge-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import { BRIDGE_API_BASE_URL } from '../../../../shared/constants/bridge';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { SWAPS_API_V2_BASE_URL } from '../../../../shared/constants/swaps';
import { flushPromises } from '../../../../test/lib/timer-helpers';
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import * as bridgeUtil from '../../../../ui/pages/bridge/bridge.util';
import * as bridgeUtil from '../../../../shared/modules/bridge-utils/bridge.util';
import * as balanceUtils from '../../../../shared/modules/bridge-utils/balance';
import mockBridgeQuotesErc20Native from '../../../../test/data/bridge/mock-quotes-erc20-native.json';
import mockBridgeQuotesNativeErc20 from '../../../../test/data/bridge/mock-quotes-native-erc20.json';
import mockBridgeQuotesNativeErc20Eth from '../../../../test/data/bridge/mock-quotes-native-erc20-eth.json';
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import { QuoteResponse } from '../../../../ui/pages/bridge/types';
import {
type QuoteResponse,
RequestStatus,
} from '../../../../shared/types/bridge';
import { decimalToHex } from '../../../../shared/modules/conversion.utils';
import BridgeController from './bridge-controller';
import { BridgeControllerMessenger } from './types';
import { DEFAULT_BRIDGE_CONTROLLER_STATE, RequestStatus } from './constants';
import { DEFAULT_BRIDGE_CONTROLLER_STATE } from './constants';

const EMPTY_INIT_STATE = {
bridgeState: DEFAULT_BRIDGE_CONTROLLER_STATE,
Expand Down
32 changes: 12 additions & 20 deletions app/scripts/controllers/bridge/bridge-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import {
fetchBridgeFeatureFlags,
fetchBridgeQuotes,
fetchBridgeTokens,
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
} from '../../../../ui/pages/bridge/bridge.util';
} from '../../../../shared/modules/bridge-utils/bridge.util';
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import { fetchTopAssetsList } from '../../../../ui/pages/swaps/swaps.util';
Expand All @@ -23,30 +21,24 @@ import {
sumHexes,
} from '../../../../shared/modules/conversion.utils';
import {
L1GasFees,
QuoteRequest,
QuoteResponse,
TxData,
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
} from '../../../../ui/pages/bridge/types';
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
import { isValidQuoteRequest } from '../../../../ui/pages/bridge/utils/quote';
type L1GasFees,
type QuoteRequest,
type QuoteResponse,
type TxData,
type BridgeControllerState,
BridgeFeatureFlagsKey,
RequestStatus,
} from '../../../../shared/types/bridge';
import { isValidQuoteRequest } from '../../../../shared/modules/bridge-utils/quote';
import { hasSufficientBalance } from '../../../../shared/modules/bridge-utils/balance';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { REFRESH_INTERVAL_MS } from '../../../../shared/constants/bridge';
import {
BRIDGE_CONTROLLER_NAME,
DEFAULT_BRIDGE_CONTROLLER_STATE,
REFRESH_INTERVAL_MS,
RequestStatus,
METABRIDGE_CHAIN_TO_ADDRESS_MAP,
} from './constants';
import {
BridgeControllerState,
BridgeControllerMessenger,
BridgeFeatureFlagsKey,
} from './types';
import type { BridgeControllerMessenger } from './types';

const metadata: StateMetadata<{ bridgeState: BridgeControllerState }> = {
bridgeState: {
Expand Down
14 changes: 4 additions & 10 deletions app/scripts/controllers/bridge/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@ import { zeroAddress } from 'ethereumjs-util';
import { Hex } from '@metamask/utils';
import {
BRIDGE_DEFAULT_SLIPPAGE,
DEFAULT_MAX_REFRESH_COUNT,
METABRIDGE_ETHEREUM_ADDRESS,
REFRESH_INTERVAL_MS,
} from '../../../../shared/constants/bridge';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { BridgeControllerState, BridgeFeatureFlagsKey } from './types';
import { BridgeFeatureFlagsKey } from '../../../../shared/types/bridge';
import type { BridgeControllerState } from '../../../../shared/types/bridge';

export const BRIDGE_CONTROLLER_NAME = 'BridgeController';
export const REFRESH_INTERVAL_MS = 30 * 1000;
const DEFAULT_MAX_REFRESH_COUNT = 5;

export enum RequestStatus {
LOADING,
FETCHED,
ERROR,
}

export const DEFAULT_BRIDGE_CONTROLLER_STATE: BridgeControllerState = {
bridgeFeatureFlags: {
[BridgeFeatureFlagsKey.EXTENSION_CONFIG]: {
Expand Down
58 changes: 6 additions & 52 deletions app/scripts/controllers/bridge/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,18 @@ import {
ControllerStateChangeEvent,
RestrictedControllerMessenger,
} from '@metamask/base-controller';
import { Hex } from '@metamask/utils';
import { AccountsControllerGetSelectedAccountAction } from '@metamask/accounts-controller';
import {
NetworkControllerFindNetworkClientIdByChainIdAction,
NetworkControllerGetSelectedNetworkClientAction,
} from '@metamask/network-controller';
import { SwapsTokenObject } from '../../../../shared/constants/swaps';
import {
L1GasFees,
QuoteRequest,
QuoteResponse,
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
} from '../../../../ui/pages/bridge/types';
import { ChainConfiguration } from '../../../../shared/types/bridge';
import type {
BridgeBackgroundAction,
BridgeControllerState,
BridgeUserAction,
} from '../../../../shared/types/bridge';
import BridgeController from './bridge-controller';
import { BRIDGE_CONTROLLER_NAME, RequestStatus } from './constants';

export enum BridgeFeatureFlagsKey {
EXTENSION_CONFIG = 'extensionConfig',
}

export type BridgeFeatureFlags = {
[BridgeFeatureFlagsKey.EXTENSION_CONFIG]: {
refreshRate: number;
maxRefreshCount: number;
support: boolean;
chains: Record<Hex, ChainConfiguration>;
};
};

export type BridgeControllerState = {
bridgeFeatureFlags: BridgeFeatureFlags;
srcTokens: Record<string, SwapsTokenObject>;
srcTopAssets: { address: string }[];
srcTokensLoadingStatus?: RequestStatus;
destTokensLoadingStatus?: RequestStatus;
destTokens: Record<string, SwapsTokenObject>;
destTopAssets: { address: string }[];
quoteRequest: Partial<QuoteRequest>;
quotes: (QuoteResponse & L1GasFees)[];
quotesInitialLoadTime?: number;
quotesLastFetched?: number;
quotesLoadingStatus?: RequestStatus;
quoteFetchError?: string;
quotesRefreshCount: number;
};

export enum BridgeUserAction {
SELECT_SRC_NETWORK = 'selectSrcNetwork',
SELECT_DEST_NETWORK = 'selectDestNetwork',
UPDATE_QUOTE_PARAMS = 'updateBridgeQuoteRequestParams',
}
export enum BridgeBackgroundAction {
SET_FEATURE_FLAGS = 'setBridgeFeatureFlags',
RESET_STATE = 'resetState',
GET_BRIDGE_ERC20_ALLOWANCE = 'getBridgeERC20Allowance',
}
import { BRIDGE_CONTROLLER_NAME } from './constants';

type BridgeControllerAction<FunctionName extends keyof BridgeController> = {
type: `${typeof BRIDGE_CONTROLLER_NAME}:${FunctionName}`;
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ import { isSnapId } from '../../ui/helpers/utils/snaps';
import { BridgeStatusAction } from '../../shared/types/bridge-status';
import { ENVIRONMENT } from '../../development/build/constants';
import fetchWithCache from '../../shared/lib/fetch-with-cache';
import {
BridgeUserAction,
BridgeBackgroundAction,
} from '../../shared/types/bridge';
import { BalancesController as MultichainBalancesController } from './lib/accounts/BalancesController';
import {
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
Expand Down Expand Up @@ -365,10 +369,6 @@ import { updateSecurityAlertResponse } from './lib/ppom/ppom-util';
import createEvmMethodsToNonEvmAccountReqFilterMiddleware from './lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware';
import { isEthAddress } from './lib/multichain/address';
import { decodeTransactionData } from './lib/transaction/decode/util';
import {
BridgeUserAction,
BridgeBackgroundAction,
} from './controllers/bridge/types';
import BridgeController from './controllers/bridge/bridge-controller';
import { BRIDGE_CONTROLLER_NAME } from './controllers/bridge/constants';
import {
Expand Down
24 changes: 21 additions & 3 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@
"TextEncoder": true
},
"packages": {
"@noble/hashes": true
"@ethereumjs/tx>ethereum-cryptography>@noble/curves>@noble/hashes": true
}
},
"@noble/hashes": {
Expand All @@ -2170,6 +2170,24 @@
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@noble/curves>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"eth-lattice-keyring>@ethereumjs/tx>ethereum-cryptography>@noble/hashes": {
"globals": {
"TextEncoder": true,
Expand Down Expand Up @@ -2248,7 +2266,7 @@
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32": {
"packages": {
"@ethereumjs/tx>ethereum-cryptography>@noble/curves": true,
"@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true,
"@metamask/utils>@scure/base": true
}
},
Expand Down Expand Up @@ -3448,7 +3466,7 @@
},
"packages": {
"@ethereumjs/tx>ethereum-cryptography>@noble/curves": true,
"@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true
}
},
Expand Down
24 changes: 21 additions & 3 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@
"TextEncoder": true
},
"packages": {
"@noble/hashes": true
"@ethereumjs/tx>ethereum-cryptography>@noble/curves>@noble/hashes": true
}
},
"@noble/hashes": {
Expand All @@ -2170,6 +2170,24 @@
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@noble/curves>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"eth-lattice-keyring>@ethereumjs/tx>ethereum-cryptography>@noble/hashes": {
"globals": {
"TextEncoder": true,
Expand Down Expand Up @@ -2248,7 +2266,7 @@
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32": {
"packages": {
"@ethereumjs/tx>ethereum-cryptography>@noble/curves": true,
"@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true,
"@metamask/utils>@scure/base": true
}
},
Expand Down Expand Up @@ -3448,7 +3466,7 @@
},
"packages": {
"@ethereumjs/tx>ethereum-cryptography>@noble/curves": true,
"@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true
}
},
Expand Down
24 changes: 21 additions & 3 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@
"TextEncoder": true
},
"packages": {
"@noble/hashes": true
"@ethereumjs/tx>ethereum-cryptography>@noble/curves>@noble/hashes": true
}
},
"@noble/hashes": {
Expand All @@ -2170,6 +2170,24 @@
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@noble/curves>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"@ethereumjs/tx>ethereum-cryptography>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"eth-lattice-keyring>@ethereumjs/tx>ethereum-cryptography>@noble/hashes": {
"globals": {
"TextEncoder": true,
Expand Down Expand Up @@ -2248,7 +2266,7 @@
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32": {
"packages": {
"@ethereumjs/tx>ethereum-cryptography>@noble/curves": true,
"@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true,
"@metamask/utils>@scure/base": true
}
},
Expand Down Expand Up @@ -3448,7 +3466,7 @@
},
"packages": {
"@ethereumjs/tx>ethereum-cryptography>@noble/curves": true,
"@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true,
"@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true
}
},
Expand Down
Loading

0 comments on commit d567eab

Please sign in to comment.