Skip to content

Commit

Permalink
Merge branch 'develop' into 17191/onboarding-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmashuang authored Jan 31, 2023
2 parents 59b22bd + 812b57d commit a7d8c44
Show file tree
Hide file tree
Showing 40 changed files with 462 additions and 196 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Added displaying the primaryType during Typed data signing ([#17077](https://github.com/MetaMask/metamask-extension/pull/17077))

## [10.24.2]
### Fixed
- Fix incorrect network information after switching networks when "Show balance and token price checker" is toggled off ([#17450](https://github.com/MetaMask/metamask-extension/pull/17450))
- Improve rendering time of signTypedData confirmation screens for large payloads ([#17432](https://github.com/MetaMask/metamask-extension/pull/17432))

## [10.24.1]
### Added
- Ensure app name appears for Taiwanese language speakers in the extension stores ([#17304](https://github.com/MetaMask/metamask-extension/pull/17304))
Expand Down Expand Up @@ -3429,7 +3434,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Uncategorized
- Added the ability to restore accounts from seed words.

[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.24.1...HEAD
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.24.2...HEAD
[10.24.2]: https://github.com/MetaMask/metamask-extension/compare/v10.24.1...v10.24.2
[10.24.1]: https://github.com/MetaMask/metamask-extension/compare/v10.24.0...v10.24.1
[10.24.0]: https://github.com/MetaMask/metamask-extension/compare/v10.23.3...v10.24.0
[10.23.3]: https://github.com/MetaMask/metamask-extension/compare/v10.23.2...v10.23.3
Expand Down
2 changes: 1 addition & 1 deletion app/_locales/de/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/el/messages.json

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

6 changes: 3 additions & 3 deletions app/_locales/en/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/es/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/fr/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/hi/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/id/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/ja/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/ko/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/pt/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/ru/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/tl/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/tr/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/vi/messages.json

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

2 changes: 1 addition & 1 deletion app/_locales/zh_CN/messages.json

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

79 changes: 54 additions & 25 deletions app/scripts/lib/buy-url.js → app/scripts/lib/buy-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { SWAPS_API_V2_BASE_URL } from '../../../shared/constants/swaps';
import {
BUYABLE_CHAINS_MAP,
CHAIN_IDS,
WyreChainSettings,
CurrencySymbol,
ChainId,
} from '../../../shared/constants/network';
import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout';
import {
Expand All @@ -18,13 +21,17 @@ const fetchWithTimeout = getFetchWithTimeout();
/**
* Create a Wyre purchase URL.
*
* @param {string} walletAddress - Ethereum destination address
* @param {string} chainId - Current chain ID
* @param {string|undefined} symbol - Token symbol to buy
* @param walletAddress - Ethereum destination address
* @param chainId - Current chain ID
* @param symbol - Token symbol to buy
* @returns String
*/
const createWyrePurchaseUrl = async (walletAddress, chainId, symbol) => {
const { wyre = {} } = BUYABLE_CHAINS_MAP[chainId];
const createWyrePurchaseUrl = async (
walletAddress: string,
chainId: keyof typeof BUYABLE_CHAINS_MAP,
symbol: CurrencySymbol,
): Promise<any> => {
const { wyre = {} as WyreChainSettings } = BUYABLE_CHAINS_MAP[chainId];
const { srn, currencyCode } = wyre;

const networkId = parseInt(chainId, 16);
Expand Down Expand Up @@ -57,12 +64,16 @@ const createWyrePurchaseUrl = async (walletAddress, chainId, symbol) => {
* Create a Transak Checkout URL.
* API docs here: https://www.notion.so/Query-Parameters-9ec523df3b874ec58cef4fa3a906f238
*
* @param {string} walletAddress - Ethereum destination address
* @param {string} chainId - Current chain ID
* @param {string|undefined} symbol - Token symbol to buy
* @param walletAddress - Ethereum destination address
* @param chainId - Current chain ID
* @param symbol - Token symbol to buy
* @returns String
*/
const createTransakUrl = (walletAddress, chainId, symbol) => {
const createTransakUrl = (
walletAddress: string,
chainId: keyof typeof BUYABLE_CHAINS_MAP,
symbol: CurrencySymbol,
): string => {
const { nativeCurrency, network } = BUYABLE_CHAINS_MAP[chainId];

const queryParams = new URLSearchParams({
Expand All @@ -79,13 +90,17 @@ const createTransakUrl = (walletAddress, chainId, symbol) => {
/**
* Create a MoonPay Checkout URL.
*
* @param {string} walletAddress - Destination address
* @param {string} chainId - Current chain ID
* @param {string|undefined} symbol - Token symbol to buy
* @param walletAddress - Destination address
* @param chainId - Current chain ID
* @param symbol - Token symbol to buy
* @returns String
*/
const createMoonPayUrl = async (walletAddress, chainId, symbol) => {
const { moonPay: { defaultCurrencyCode, showOnlyCurrencies } = {} } =
const createMoonPayUrl = async (
walletAddress: string,
chainId: keyof typeof BUYABLE_CHAINS_MAP,
symbol: CurrencySymbol,
): Promise<string> => {
const { moonPay: { defaultCurrencyCode, showOnlyCurrencies } = {} as any } =
BUYABLE_CHAINS_MAP[chainId];
const moonPayQueryParams = new URLSearchParams({
apiKey: MOONPAY_API_KEY,
Expand Down Expand Up @@ -121,12 +136,16 @@ const createMoonPayUrl = async (walletAddress, chainId, symbol) => {
/**
* Create a Coinbase Pay Checkout URL.
*
* @param {string} walletAddress - Ethereum destination address
* @param {string} chainId - Current chain ID
* @param {string|undefined} symbol - Token symbol to buy
* @param walletAddress - Ethereum destination address
* @param chainId - Current chain ID
* @param symbol - Token symbol to buy
* @returns String
*/
const createCoinbasePayUrl = (walletAddress, chainId, symbol) => {
const createCoinbasePayUrl = (
walletAddress: string,
chainId: keyof typeof BUYABLE_CHAINS_MAP,
symbol: CurrencySymbol,
): string => {
// since coinbasePayCurrencies is going to be extended to include all tokens supported
// we now default to nativeCurrency instead of the 2 previous tokens + eth that we had before
const { nativeCurrency } = BUYABLE_CHAINS_MAP[chainId];
Expand All @@ -146,15 +165,25 @@ const createCoinbasePayUrl = (walletAddress, chainId, symbol) => {
/**
* Gives the caller a url at which the user can acquire eth, depending on the network they are in
*
* @param {object} opts - Options required to determine the correct url
* @param {string} opts.chainId - The chainId for which to return a url
* @param {string} opts.address - The address the bought ETH should be sent to. Only relevant if chainId === '0x1'.
* @param opts - Options required to determine the correct url
* @param opts.chainId - The chainId for which to return a url
* @param opts.address - The address the bought ETH should be sent to. Only relevant if chainId === '0x1'.
* @param opts.service
* @param {string|undefined} opts.symbol - The symbol of the token to buy. Only relevant if buying a token.
* @returns {string|undefined} The url at which the user can access ETH, while in the given chain. If the passed
* @param opts.symbol - The symbol of the token to buy. Only relevant if buying a token.
* @returns The url at which the user can access ETH, while in the given chain. If the passed
* chainId does not match any of the specified cases, or if no chainId is given, returns undefined.
*/
export default async function getBuyUrl({ chainId, address, service, symbol }) {
export default async function getBuyUrl({
chainId,
address,
service,
symbol,
}: {
chainId: keyof typeof BUYABLE_CHAINS_MAP;
address: string;
service: string;
symbol: CurrencySymbol;
}): Promise<string> {
// default service by network if not specified
if (!service) {
// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -183,7 +212,7 @@ export default async function getBuyUrl({ chainId, address, service, symbol }) {
}
}

function getDefaultServiceForChain(chainId) {
function getDefaultServiceForChain(chainId: ChainId): string {
switch (chainId) {
case CHAIN_IDS.MAINNET:
return 'wyre';
Expand Down
4 changes: 4 additions & 0 deletions development/verify-locale-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,19 @@ async function verifyEnglishLocale() {
// and gradually phase out the key based search
const globsToStrictSearch = [
'ui/components/app/metamask-translation/*.js',
'ui/components/app/metamask-translation/*.ts',
'ui/pages/confirmation/templates/*.js',
'ui/pages/confirmation/templates/*.ts',
];
const testGlob = '**/*.test.js';
const javascriptFiles = await glob(
[
'ui/**/*.js',
'ui/**/*.ts',
'shared/**/*.js',
'shared/**/*.ts',
'app/scripts/constants/**/*.js',
'app/scripts/constants/**/*.ts',
],
{
ignore: [...globsToStrictSearch, testGlob],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metamask-crx",
"version": "10.24.1",
"version": "10.24.2",
"private": true,
"repository": {
"type": "git",
Expand Down Expand Up @@ -92,6 +92,7 @@
},
"resolutions": {
"analytics-node/axios": "^0.21.2",
"cookiejar": "^2.1.4",
"ganache-core/lodash": "^4.17.21",
"netmask": "^2.0.1",
"pubnub/superagent-proxy": "^3.0.0",
Expand All @@ -110,7 +111,6 @@
"eslint-import-resolver-typescript@^2.5.0": "patch:eslint-import-resolver-typescript@npm%3A2.5.0#./.yarn/patches/eslint-import-resolver-typescript-npm-2.5.0-3b8adf0d03.patch",
"[email protected]": "patch:colors@npm%3A1.4.0#./.yarn/patches/colors-npm-1.4.0-7e2cf12234.patch",
"[email protected]": "patch:colors@npm%3A1.4.0#./.yarn/patches/colors-npm-1.4.0-7e2cf12234.patch",
"cookiejar": "^2.1.4",
"borc@^2.1.2": "patch:borc@npm%3A2.1.2#./.yarn/patches/borc-npm-2.1.2-8ffcc2dd81.patch",
"borc@^2.1.0": "patch:borc@npm%3A2.1.2#./.yarn/patches/borc-npm-2.1.2-8ffcc2dd81.patch",
"convert-source-map@^1.7.0": "patch:convert-source-map@npm%3A1.1.3#./.yarn/patches/convert-source-map-npm-1.1.3-7f1bfeabd4.patch",
Expand Down Expand Up @@ -306,7 +306,7 @@
"labeled-stream-splicer": "^2.0.2",
"localforage": "^1.9.0",
"lodash": "^4.17.21",
"loglevel": "^1.4.1",
"loglevel": "^1.8.1",
"luxon": "^3.2.1",
"nanoid": "^2.1.6",
"nonce-tracker": "^1.0.0",
Expand Down
9 changes: 5 additions & 4 deletions shared/constants/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export type ChainId = typeof CHAIN_IDS[keyof typeof CHAIN_IDS];
* This type is non-exhaustive, and cannot be used for areas where the user
* or dapp may supply their own symbol.
*/
type CurrencySymbol = typeof CURRENCY_SYMBOLS[keyof typeof CURRENCY_SYMBOLS];
export type CurrencySymbol =
typeof CURRENCY_SYMBOLS[keyof typeof CURRENCY_SYMBOLS];
/**
* A type that is a union type for the supported symbols on different onramp providers.
*/
Expand All @@ -41,7 +42,7 @@ type MoonPayNetworkAbbreviation = 'BSC' | 'CCHAIN' | 'POLYGON';
* MoonPay requires some settings that are configured per network that it is
* enabled on. This type describes those settings.
*/
type MoonPayChainSettings = {
export type MoonPayChainSettings = {
/**
* What should the default onramp currency be, for example 'eth' on 'mainnet'
* This type matches a single SupportedCurrencySymbol or a
Expand Down Expand Up @@ -77,7 +78,7 @@ type RPCPreferences = {
/**
* An object that describes a network to be used inside of MetaMask
*/
type RPCDefinition = {
export type RPCDefinition = {
/**
* The hex encoded ChainId for the network
*/
Expand All @@ -104,7 +105,7 @@ type RPCDefinition = {
* Wyre is a fiat onramp provider. We must provide some settings for networks
* that support Wyre.
*/
type WyreChainSettings = {
export type WyreChainSettings = {
/**
* The network name
*/
Expand Down
Loading

0 comments on commit a7d8c44

Please sign in to comment.