1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #11564 from MetaMask/Version-v9.8.2

Version v9.8.2 RC
This commit is contained in:
ryanml 2021-07-21 19:43:04 -07:00 committed by GitHub
commit 281aea7d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 4 deletions

View File

@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [9.8.2]
### Changed
- [1156511545](https://github.com/MetaMask/metamask-extension/pull/11545): Allow MetaMask Swaps to support Polygon network
### Fixed
- [11565](https://github.com/MetaMask/metamask-extension/pull/11565): Fix gas limit estimation for some tokens on custom networks
- [11581](https://github.com/MetaMask/metamask-extension/pull/11581): Fixed bug that resulted in sends to some contracts being disabled.
## [9.8.1] ## [9.8.1]
### Changed ### Changed
- Adjusting transaction metrics values - Adjusting transaction metrics values
@ -2336,7 +2344,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Uncategorized ### Uncategorized
- Added the ability to restore accounts from seed words. - Added the ability to restore accounts from seed words.
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v9.8.1...HEAD [Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v9.8.2...HEAD
[9.8.2]: https://github.com/MetaMask/metamask-extension/compare/v9.8.1...v9.8.2
[9.8.1]: https://github.com/MetaMask/metamask-extension/compare/v9.8.0...v9.8.1 [9.8.1]: https://github.com/MetaMask/metamask-extension/compare/v9.8.0...v9.8.1
[9.8.0]: https://github.com/MetaMask/metamask-extension/compare/v9.7.1...v9.8.0 [9.8.0]: https://github.com/MetaMask/metamask-extension/compare/v9.7.1...v9.8.0
[9.7.1]: https://github.com/MetaMask/metamask-extension/compare/v9.7.0...v9.7.1 [9.7.1]: https://github.com/MetaMask/metamask-extension/compare/v9.7.0...v9.7.1

BIN
app/images/matic-token.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,6 +1,6 @@
{ {
"name": "metamask-crx", "name": "metamask-crx",
"version": "9.8.1", "version": "9.8.2",
"private": true, "private": true,
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -49,10 +49,12 @@ export const ETH_SYMBOL = 'ETH';
export const WETH_SYMBOL = 'WETH'; export const WETH_SYMBOL = 'WETH';
export const TEST_ETH_SYMBOL = 'TESTETH'; export const TEST_ETH_SYMBOL = 'TESTETH';
export const BNB_SYMBOL = 'BNB'; export const BNB_SYMBOL = 'BNB';
export const MATIC_SYMBOL = 'MATIC';
export const ETH_TOKEN_IMAGE_URL = './images/eth_logo.svg'; export const ETH_TOKEN_IMAGE_URL = './images/eth_logo.svg';
export const TEST_ETH_TOKEN_IMAGE_URL = './images/black-eth-logo.svg'; export const TEST_ETH_TOKEN_IMAGE_URL = './images/black-eth-logo.svg';
export const BNB_TOKEN_IMAGE_URL = './images/bnb.png'; export const BNB_TOKEN_IMAGE_URL = './images/bnb.png';
export const MATIC_TOKEN_IMAGE_URL = './images/matic-token.png';
export const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI]; export const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI];

View File

@ -6,6 +6,9 @@ import {
TEST_ETH_TOKEN_IMAGE_URL, TEST_ETH_TOKEN_IMAGE_URL,
BNB_TOKEN_IMAGE_URL, BNB_TOKEN_IMAGE_URL,
BSC_CHAIN_ID, BSC_CHAIN_ID,
POLYGON_CHAIN_ID,
MATIC_SYMBOL,
MATIC_TOKEN_IMAGE_URL,
} from './network'; } from './network';
export const QUOTES_EXPIRED_ERROR = 'quotes-expired'; export const QUOTES_EXPIRED_ERROR = 'quotes-expired';
@ -35,6 +38,14 @@ export const BNB_SWAPS_TOKEN_OBJECT = {
iconUrl: BNB_TOKEN_IMAGE_URL, iconUrl: BNB_TOKEN_IMAGE_URL,
}; };
export const MATIC_SWAPS_TOKEN_OBJECT = {
symbol: MATIC_SYMBOL,
name: 'Matic',
address: DEFAULT_TOKEN_ADDRESS,
decimals: 18,
iconUrl: MATIC_TOKEN_IMAGE_URL,
};
export const TEST_ETH_SWAPS_TOKEN_OBJECT = { export const TEST_ETH_SWAPS_TOKEN_OBJECT = {
symbol: TEST_ETH_SYMBOL, symbol: TEST_ETH_SYMBOL,
name: 'Test Ether', name: 'Test Ether',
@ -52,6 +63,9 @@ const TESTNET_CONTRACT_ADDRESS = '0x881d40237659c251811cec9c364ef91dc08d300c';
const BSC_CONTRACT_ADDRESS = '0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31'; const BSC_CONTRACT_ADDRESS = '0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31';
// It's the same as we use for BSC.
const POLYGON_CONTRACT_ADDRESS = '0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31';
export const ETH_WETH_CONTRACT_ADDRESS = export const ETH_WETH_CONTRACT_ADDRESS =
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
@ -64,13 +78,16 @@ const SWAPS_TESTNET_HOST = 'https://metaswap-api.airswap-dev.codefi.network';
const BSC_DEFAULT_BLOCK_EXPLORER_URL = 'https://bscscan.com/'; const BSC_DEFAULT_BLOCK_EXPLORER_URL = 'https://bscscan.com/';
const MAINNET_DEFAULT_BLOCK_EXPLORER_URL = 'https://etherscan.io/'; const MAINNET_DEFAULT_BLOCK_EXPLORER_URL = 'https://etherscan.io/';
const POLYGON_DEFAULT_BLOCK_EXPLORER_URL = 'https://polygonscan.com/';
export const ALLOWED_SWAPS_CHAIN_IDS = { export const ALLOWED_SWAPS_CHAIN_IDS = {
[MAINNET_CHAIN_ID]: true, [MAINNET_CHAIN_ID]: true,
[SWAPS_TESTNET_CHAIN_ID]: true, [SWAPS_TESTNET_CHAIN_ID]: true,
[BSC_CHAIN_ID]: true, [BSC_CHAIN_ID]: true,
[POLYGON_CHAIN_ID]: true,
}; };
// This is mapping for v1 URLs and will be removed once we migrate to v2.
export const METASWAP_CHAINID_API_HOST_MAP = { export const METASWAP_CHAINID_API_HOST_MAP = {
[MAINNET_CHAIN_ID]: METASWAP_ETH_API_HOST, [MAINNET_CHAIN_ID]: METASWAP_ETH_API_HOST,
[SWAPS_TESTNET_CHAIN_ID]: SWAPS_TESTNET_HOST, [SWAPS_TESTNET_CHAIN_ID]: SWAPS_TESTNET_HOST,
@ -81,17 +98,20 @@ export const SWAPS_CHAINID_CONTRACT_ADDRESS_MAP = {
[MAINNET_CHAIN_ID]: MAINNET_CONTRACT_ADDRESS, [MAINNET_CHAIN_ID]: MAINNET_CONTRACT_ADDRESS,
[SWAPS_TESTNET_CHAIN_ID]: TESTNET_CONTRACT_ADDRESS, [SWAPS_TESTNET_CHAIN_ID]: TESTNET_CONTRACT_ADDRESS,
[BSC_CHAIN_ID]: BSC_CONTRACT_ADDRESS, [BSC_CHAIN_ID]: BSC_CONTRACT_ADDRESS,
[POLYGON_CHAIN_ID]: POLYGON_CONTRACT_ADDRESS,
}; };
export const SWAPS_CHAINID_DEFAULT_TOKEN_MAP = { export const SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {
[MAINNET_CHAIN_ID]: ETH_SWAPS_TOKEN_OBJECT, [MAINNET_CHAIN_ID]: ETH_SWAPS_TOKEN_OBJECT,
[SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT, [SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT,
[BSC_CHAIN_ID]: BNB_SWAPS_TOKEN_OBJECT, [BSC_CHAIN_ID]: BNB_SWAPS_TOKEN_OBJECT,
[POLYGON_CHAIN_ID]: MATIC_SWAPS_TOKEN_OBJECT,
}; };
export const SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP = { export const SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP = {
[BSC_CHAIN_ID]: BSC_DEFAULT_BLOCK_EXPLORER_URL, [BSC_CHAIN_ID]: BSC_DEFAULT_BLOCK_EXPLORER_URL,
[MAINNET_CHAIN_ID]: MAINNET_DEFAULT_BLOCK_EXPLORER_URL, [MAINNET_CHAIN_ID]: MAINNET_DEFAULT_BLOCK_EXPLORER_URL,
[POLYGON_CHAIN_ID]: POLYGON_DEFAULT_BLOCK_EXPLORER_URL,
}; };
export const ETHEREUM = 'ethereum'; export const ETHEREUM = 'ethereum';

View File

@ -183,8 +183,19 @@ async function estimateGasLimitForSend({
let isSimpleSendOnNonStandardNetwork = false; let isSimpleSendOnNonStandardNetwork = false;
// blockGasLimit may be a falsy, but defined, value when we receive it from // blockGasLimit may be a falsy, but defined, value when we receive it from
// state, so we use logical or to fall back to MIN_GAS_LIMIT_HEX. // state, so we use logical or to fall back to MIN_GAS_LIMIT_HEX. Some
const blockGasLimit = options.blockGasLimit || MIN_GAS_LIMIT_HEX; // network implementations check the gas parameter supplied to
// eth_estimateGas for validity. For this reason, we set token sends
// blockGasLimit default to a higher number. Note that the current gasLimit
// on a BLOCK is 15,000,000 and will be 30,000,000 on mainnet after London.
// Meanwhile, MIN_GAS_LIMIT_HEX is 0x5208.
let blockGasLimit = MIN_GAS_LIMIT_HEX;
if (options.blockGasLimit) {
blockGasLimit = options.blockGasLimit;
} else if (sendToken) {
blockGasLimit = GAS_LIMITS.BASE_TOKEN_ESTIMATE;
}
// The parameters below will be sent to our background process to estimate // The parameters below will be sent to our background process to estimate
// how much gas will be used for a transaction. That background process is // how much gas will be used for a transaction. That background process is
// located in tx-gas-utils.js in the transaction controller folder. // located in tx-gas-utils.js in the transaction controller folder.
@ -1026,6 +1037,11 @@ const slice = createSlice({
}); });
} }
}) })
.addCase(computeEstimatedGasLimit.rejected, (state) => {
// If gas estimation fails, we should set the loading state to false,
// because it is no longer loading
state.gas.isGasEstimateLoading = false;
})
.addCase(SET_BASIC_GAS_ESTIMATE_DATA, (state, action) => { .addCase(SET_BASIC_GAS_ESTIMATE_DATA, (state, action) => {
// When we receive a new gasPrice via the gas duck we need to update // When we receive a new gasPrice via the gas duck we need to update
// the gasPrice in our slice. We call into the caseReducer // the gasPrice in our slice. We call into the caseReducer

View File

@ -77,6 +77,9 @@ const getBaseApi = function (
const baseUrl = useNewSwapsApi const baseUrl = useNewSwapsApi
? getBaseUrlForNewSwapsApi(type, chainId) ? getBaseUrlForNewSwapsApi(type, chainId)
: METASWAP_CHAINID_API_HOST_MAP[chainId]; : METASWAP_CHAINID_API_HOST_MAP[chainId];
if (!baseUrl) {
throw new Error(`Swaps API calls are disabled for chainId: ${chainId}`);
}
switch (type) { switch (type) {
case 'trade': case 'trade':
return `${baseUrl}/trades?`; return `${baseUrl}/trades?`;